Log in

View Full Version : Loop in New Depot



blah88
12-19-2015, 12:28 PM
Hello,

I know that new depots are like backpacks and can be accessed by any depot... Anyway I need access a backpack inside a depot box, because I send a backpack with items to another character to be sold(green djin, blue djin, rafzan, yasir)


local IDDepot = 22797

Self.CloseContainers()

local Depot = Self.OpenDepot()

for i = 0, Depot:ItemCount()-1 do
if (Depot:GetItemData(i).id == IDDepot) then
Depot:UseItem(i, true)

--local dpBox = Container.New('depot box I') return 17 item
--local dpBox = Container.New(IDDepot) return 0
--local dpBox = Container.GetLast() return 17 item
--local dpBox = Container:Index() return nil
--local dpBox = Container:ItemCount() return 17 item
--Container:ItemCount() return 17 item
--local dpBox = Container:OpenChildren('depot box I')return nil
--local dpBox = Container.GetByName('depot box I') return 0
--local dpBox = Container.GetByName(IDDepot) return 0
print(dpBox:ItemCount())

break;
end
end


That's the small script that I have been using to test... It opens depot chest wich has 17 items(depot box) then open depot box I(wich has only one item a brocade backpack).

In my test it just shows me 17 items that means depot box or nil or return 0.

Anyway, someone would have any suggestions for how to loop inside the depot box?

blah88
12-23-2015, 09:55 PM
Hello,

In all my tries I figured out that when I use the ID of depot box(code below) xeno opens the depot box...



local itemData = Depot:GetItemData(i)
if (itemData.id == IDDepot) then
Depot:UseItem(i, true)


But, when I use the depot box name it doesn't open nothing..
Code:


local itemData = Depot:GetItemData(i)
if (Item.GetName(itemData.id) == 'depot box I') then
Depot:UseItem(i, true)

What I would like to know is, the fact xeno do not recognize the name means that it can not return any instance of a container when using Container.GetLast(),Container.New('depot box I')? Because when I trying do it, just return the depot chest with 17 items(depot box)

blah88
12-29-2015, 09:18 PM
Someone??

L!p3
12-30-2015, 01:16 AM
If you are with the Depot Box opened and use Container.GetLast():Name() u will see that the right way to type this containers names are: "Depot Box Number", and capital letters does matter.
As the Depot Box have IDs 22797, 22798, 22799 and so on, you can make a function to do like: Container.OpenDPBox(num), or UseItem(22796 + num, true) and the 'num' you just do 22796 + 'num'.

blah88
12-30-2015, 09:58 PM
Using this small code I get those results:

- With depot chest opened it returns: unknown x17

- With depot box I opened it returns: brocade backpack (that's what I want, but must be automatic...Self.OpenDepot()...)


local container = Container.GetLast()

for i=0, container:ItemCount()-1 do
local itemData = container:GetItemData(slot)
print(Item.GetName(itemData.id) )
end


That's the code I've been using to access a backpack inside Depot Box



local IDDepot = 22797
Self.CloseContainers()

local DepotChest = Self.OpenDepot()


for i = 0, DepotChest:ItemCount()-1 do
if (DepotChest:GetItemData(i).id == IDDepot) then
DepotChest:UseItem(i, true)-- until here it's open depot box I, after that nothing happens...

local depotBox = Container.GetLast() --return unknown
--local depotBox = Container.New('Depot Box I') --return nothimg
--local depotBox = Container.New(Item.GetName(IDDepot)) --return nothing
--local depotBox = Container.New(IDDepot) --return nothing

for j = 0, depotBox:ItemCount()-1 do
local itemData = depotBox:GetItemData(j)
print(Item.GetName(itemData.id))
end

break
end
end


It needs to open(automatic) a backpack inside a depot... because I need move items from inbox for that bp...

L!p3
12-30-2015, 11:04 PM
Using this small code I get those results:

- With depot chest opened it returns: unknown x17

- With depot box I opened it returns: brocade backpack (that's what I want, but must be automatic...Self.OpenDepot()...)


local container = Container.GetLast()

for i=0, container:ItemCount()-1 do
local itemData = container:GetItemData(slot)
print(Item.GetName(itemData.id) )
end


That's the code I've been using to access a backpack inside Depot Box



local IDDepot = 22797
Self.CloseContainers()

local DepotChest = Self.OpenDepot()


for i = 0, DepotChest:ItemCount()-1 do
if (DepotChest:GetItemData(i).id == IDDepot) then
DepotChest:UseItem(i, true)-- until here it's open depot box I, after that nothing happens...

local depotBox = Container.GetLast() --return unknown
--local depotBox = Container.New('Depot Box I') --return nothimg
--local depotBox = Container.New(Item.GetName(IDDepot)) --return nothing
--local depotBox = Container.New(IDDepot) --return nothing

for j = 0, depotBox:ItemCount()-1 do
local itemData = depotBox:GetItemData(j)
print(Item.GetName(itemData.id))
end

break
end
end


It needs to open(automatic) a backpack inside a depot... because I need move items from inbox for that bp...

local DPBox = 1 -- From 1 to 17.
local BPName = "Brocade Backpack"

Self.CloseContainers()
Self.OpenDepot()

local DPChest = Container.GetLast()
for i = 0, DPChest:ItemCount()-1 do
if (DPChest:GetItemData(i).id == 22796 + DPBox) then
DPChest:UseItem(i, true) wait(Self.Ping() * 2, Self.Ping() * 3)

for j = 0, DPChest:ItemCount()-1 do
if (DPChest:GetItemData(j).id == Item.GetID(BPName)) then
DPChest:UseItem(j, true) wait(Self.Ping() * 2, Self.Ping() * 3)
end
end
end
end

blah88
01-01-2016, 02:08 PM
worked perfectly, thank you.