Zyntax
*WannaBe Scripter*
update:
I'm as far as scanning for every BPs UID.
How to know which backpack belongs where and how to stack them backwards?
I guess this is too challenging...
I'm as far as scanning for every BPs UID.
How to know which backpack belongs where and how to stack them backwards?
Code:
local function scanBp(uid, t)
local con = Container(uid)
print("scanbp "..#t.." size: "..con:getSize().." uid = "..uid)
for i = (con:getSize()-1),0, -1 do
local it = Item(con:getItem(i):getUniqueId())
if it ~= nil then
local type = ItemType(it:getId())
if type:isContainer() then
local uid = con:getItem(i):getUniqueId()
table.insert(t, uid)
scanBp(uid, t)
end
end
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local p = Player(cid)
local bp = p:getSlotItem(3):getUniqueId()
local t = {}
scanBp(bp,t)
--[[
local p = Player(cid)
local dp = {}
local old = Item(p:getSlotItem(3):getUniqueId())
local oldc = Container(p:getSlotItem(3):getUniqueId())
local i = 0
local new = Game.createItem(old:getId(),1)
local newc = Container(new:getUniqueId())
while i < oldc:getSize() do
local it = Item(oldc:getItem(i):getUniqueId())
local type = ItemType(it:getId())
if it ~= nil then
newc:addItem(it:getId(), it:getCount())
end
i = i+1
end
p:addItemEx(newc)
--]]
return true
end
I guess this is too challenging...
Last edited: