Skip to content

Commit

Permalink
Fix item duplications for water containers
Browse files Browse the repository at this point in the history
  • Loading branch information
jhaakma committed Dec 31, 2023
1 parent 0b688d6 commit 7bd3ff4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Data Files/MWSE/mods/mer/ashfall/heat/HeatUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ local HEAT_LOSS_FULL = 1.0
local WATER_HEAT_RATE = 40--base water heat/cooling speed
---@param liquidContainer Ashfall.LiquidContainer
function HeatUtil.updateWaterHeat(liquidContainer)
if not liquidContainer.waterAmount then return end
if liquidContainer.waterAmount <= 0 then return end
local now = tes3.getSimulationTimestamp()
liquidContainer.lastWaterUpdated = liquidContainer.lastWaterUpdated or now
local timeSinceLastUpdate = now - liquidContainer.lastWaterUpdated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ end
---@param reference tes3reference
---@return Ashfall.LiquidContainer|nil liquidContainer
function LiquidContainer.createFromReference(reference, bottleData)
if not reference.supportsLuaData then return nil end
local id = (reference.data and reference.data.utensilId) or reference.baseObject.id
return LiquidContainer.new{
id = id,
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 @@ -376,7 +376,7 @@ event.register("cellChanged", addWaterToWorld)

---@param e itemDroppedEventData
local function clearDataOnDrop(e)
if e.reference.data then
if e.reference.supportsLuaData then
e.reference.data.lastWaterUpdated = nil
e.reference.data.lastBrewUpdated = nil
e.reference.data.lastStewUpdated = nil
Expand Down
14 changes: 4 additions & 10 deletions Data Files/MWSE/mods/mer/ashfall/referenceController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,13 @@ this.controllers = {
fuelConsumer = ReferenceController:new{
requirements = function(_, ref)
return ref.supportsLuaData
and ref.data
and ref.data.fuelLevel
end
},

boiler = ReferenceController:new{
requirements = function(_, ref)
local isboiler = ref.supportsLuaData
and ref.data
and ref.data.waterHeat ~= nil
return isboiler
end
Expand All @@ -77,33 +75,29 @@ this.controllers = {
stewer = ReferenceController:new{
requirements = function(_, ref)
return ref.supportsLuaData
and ref.data
and ref.data.utensil == "cookingPot"
or staticConfigs.cookingPots[ref.object.id:lower()]
and (ref.data.utensil == "cookingPot"
or staticConfigs.cookingPots[ref.object.id:lower()])
end,
},

brewer = ReferenceController:new{
requirements = function(_, ref)
return ref.supportsLuaData
and ref.data
and ref.data.utensil == "kettle"
or staticConfigs.kettles[ref.object.id:lower()]
and (ref.data.utensil == "kettle"
or staticConfigs.kettles[ref.object.id:lower()])
end
},

stewBuffedActor = ReferenceController:new{
requirements = function(_, ref)
return ref.supportsLuaData
and ref.data
and ref.data.stewBuffTimeLeft
end
},

teaBuffedActor = ReferenceController:new{
requirements = function(_, ref)
return ref.supportsLuaData
and ref.data
and ref.data.teaBuffTimeLeft
end
},
Expand Down

0 comments on commit 7bd3ff4

Please sign in to comment.