But isn't the depot locker a container? Tried to loop through it?
Hmm, a container doesn't seem to have a getItems function like a tile has? (or the docs is bad)
Item metatable
A free and open-source MMORPG server emulator written in C++ - otland/forgottenserver
github.com
Verify an item is a container:
item:isContainer()
Container metatable:
A free and open-source MMORPG server emulator written in C++ - otland/forgottenserver
github.com
Length/max index of items in this container:
Container:getItemHoldingCount()
Retrieve item of an iterated index:
Container:getItem(index)
Lua:
-- Generic dump to string function
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
-- Search a container, returning countainers inside... this container
function searchContainer(containerItem)
-- Failsafe
if containerItem == nil or not containerItem:isContainer() then
print("Function searchContainer used without passing in a proper container")
return false
end
local containers = []
-- actual search
local maxIndex = containerItem:getItemHoldingCount()
for i=1, maxIndex do -- Might need to add +1 or -1 to maxIndex to get the complete loop, Lua indexing is weird
local item = containerItem:getItem(i)
if item:isContainer() then
table.insert(containers, item)
end
end
return containers
end
-- (-.(^.-(^.^)-.^).-) start of my drunk code
function helloWorld(locker)
if locker == nil or not locker:isItem() then
print("input locker parameter not even recognized as an item")
return false
end
if not locker:isContainer() then
print("Locker (".. locker:getItemId() ..") is not a container???")
return false
end
local containers = searchContainer(locker)
-- Lets have a look into containers inside locker
print("Containers: ".. dump(containers))
end