I am trying to iterate over the slots inside player depot locker and find a specific container but I haven't found a way to do it.
OTLAND, SHOW ME DA WEY!
KKHHHT! SPITS
OTLAND, SHOW ME DA WEY!
KKHHHT! SPITS
-- 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
![]()
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
![]()
Metatable:Item
A free and open-source MMORPG server emulator written in C++ - otland/forgottenservergithub.com
Verify an item is a container:
item:isContainer()
Container metatable:
![]()
Metatable:Container
A free and open-source MMORPG server emulator written in C++ - otland/forgottenservergithub.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
Game.createContainer(ItemID, size). The idea is to create a virtual container and add it to the player. once the V.Container is created it should open as a normal bag would in the right panel, but it wont. I have asked the question on the discord channel . But nobody has responded about that question. Do you know why it won't open the (virtual)container ? (should I just make a new thread about this ?)