I am having so many problems with this function
if not container then return false end
local key = tostring(container)
local required = 0
local comp = nil
if item and item.getFullType then
local fullType = item:getFullType()
local scriptItem = ScriptManager.instance:FindItem(fullType)
if scriptItem and type(scriptItem.getModData) == "function" then
local modData = scriptItem:getModData()
if modData and modData["Component"] and modData["Component"]["FluidContainer"] then
local ok, result = pcall(function() return item:getComponent("FluidContainer") end)
if ok then comp = result end
end
end
end
if comp then
local baseWeight = item:getWeight()
local amount = comp.getAmount and comp:getAmount() or 0
local fluidMult = 1.0 -- default multiplier
local fluidWeight = amount * fluidMult
required = baseWeight + fluidWeight
debugPrint("Item:", item:getFullType(), "Base:", baseWeight, "Amount:", amount, "Fluid Weight:", fluidWeight, "Total:", required)
else
required = (item.getWeight and item:getWeight()) or 0
debugPrint("Item:", item:getFullType(), "Total:", required)
end
local capacity = container:getEffectiveCapacity(playerObj)
local used = container:getContentsWeight()
local pending = stackAllMemo[key] or 0
return (capacity - used - pending) >= required
end
The problem is that I cannot get (Sealed Fluidcontainers) to give me the Correct weight, from all the getWeight properties it only shows the weight of the container, but it should be (Weight + (FluidContainer Capacity * Fluid Weight per Unit) So example a diet cola should be (0.3 + (0.3 * 1.0) which shows as 0.6 in the tooltip.
Trying to access the properties via the script, or with pcalls like to crash so much.