Hello.
I can only think in two ways to count a container's weight:
1. If you know all items weight and iterate over all items on container. Bot don't have know items weight, so you would need to manually setup.
local CONFIG = {
{ Container = 'brown backpack', MinWeight = 60 }, -- Container Index, id or name and its minimum weight.
{ Container = 'blue backpack', MinWeight = 120 },
}
local ITEMS = {
{ Id = 3031, Weight = 0.1 },
{ Id = 3035, Weight = 0.1 },
}
for _, config in ipairs(CONFIG) do
local cont = getcontainer(config.Container)
local weight = 0
local flag = false
for __, item in ipairs(cont.items) do
for ___, itemInfo in ipairs(ITEMS) do
if item.id == itemInfo.Id then
flag = true
weight = weight + itemInfo.Weight
end
end
end
if flag and weight < config.MinWeight then
gotolabel('refill')
return
end
end
gotolabel('continue 1')
2. Using context menu (right-click + "Look") and checking the message.
local MAIN_BP = 'red backpack' -- Container index, id or name
local CONFIG = {
{ ContainerId = 2854, MinWeight = 60 }, -- ID of container that is inside main bp to check weight. and its minimum weight.
{ ContainerId = 2869, MinWeight = 120 },
}
local weightMessagePattern = 'It weighs (%d*%.?%d+) oz'
for _, config in ipairs(CONFIG) do
if contextmenucontainer('Look', MAIN_BP, config.ContainerId) then
local msg = screenmessage(true, '3')
if msg ~= nil and msg ~= '' then
local weight_str = string.match(msg, weightMessagePattern)
if weight_str ~= nil then
local weight = tonumber(weight_str)
if weight ~= nil and weight < config.MinWeight then
gotolabel('refill')
return
end
end
end
end
end
gotolabel('continue 1')