Skip to content

Commit

Permalink
Fix splash sounds when drinking from water container
Browse files Browse the repository at this point in the history
  • Loading branch information
jhaakma committed Apr 17, 2023
1 parent c07e75a commit de1a54e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions Data Files/MWSE/mods/mer/ashfall/liquid/LiquidContainer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ local teaConfig = require "mer.ashfall.config.teaConfig"
---@field stewBuffs table The stew buffs
---@field capacity number Maximum water capacity of container
---@field holdsStew boolean Flag whether container is able to hold stew. If it can hold stew, it can't hold tea.
---@field doPlaySound boolean *Default*: `true`. Flag whether to play a sound when adding water to the container
local LiquidContainer = {}

local dataValues = {
Expand Down Expand Up @@ -122,6 +123,7 @@ function LiquidContainer.new(e)
liquidContainer.holdsStew = bottleData.holdsStew == true
liquidContainer.reference = reference
liquidContainer.itemId = id
liquidContainer.doPlaySound = true
setmetatable(liquidContainer, meta )
if liquidContainer.stewLevels then liquidContainer.waterType = "stew" end
return liquidContainer
Expand Down Expand Up @@ -406,12 +408,20 @@ function LiquidContainer:doGraphicalUpdates()
tes3ui.updateInventoryTiles()
end

---@param self Ashfall.LiquidContainer
---@param bool boolean #Whether to play the water transfer sound when this container is filled or emptied
function LiquidContainer:setPlaySound(bool)
self.doPlaySound = bool
end

function LiquidContainer:playSound()
tes3.playSound({reference = tes3.player, sound = "ashfall_water"})
if self.doPlaySound then
tes3.playSound({reference = tes3.player, sound = "ashfall_water"})
end
end

---@alias Ashfall.LiquidContainer.LiquidName
---| '"Dirty Water"'
---| '"Dirty water"'
---| '"Water"'
---| '"Stew"'
---| '"Soup"'
Expand Down
2 changes: 1 addition & 1 deletion Data Files/MWSE/mods/mer/ashfall/needs/waterController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ local function douse(bottleData)
common.data.wetness = common.data.wetness + waterUsed*wetnessPerWater
event.trigger("Ashfall:updateCondition", { id = "wetness" })


--handle bottleData if provided
if bottleData then
local liquidContainer = LiquidContainer.createFromData(bottleData)
Expand Down Expand Up @@ -204,6 +203,7 @@ local function doDrinkWater(bottleData)
--Reduce liquid in bottleData
local liquidContainer = LiquidContainer.createFromData(bottleData)
if liquidContainer then
liquidContainer:setPlaySound(false)
liquidContainer:reduce(thisSipSize)
end
end
Expand Down

0 comments on commit de1a54e

Please sign in to comment.