Signup Now
Results 1 to 4 of 4
  1. #1
    Free User pedegie's Avatar
    Join Date
    Dec 2015
    Location
    Poland
    Posts
    264
    Reputation
    28
    Rep Power
    17

    Trying to open all visible backpacks

    Im trying to open all visible backpacks. I have persistent which counts items inside backpacks so its fine if I open each one just for a moment only. I have many backpacks inside other backpacks with diffrent colors. For now i have something like this :

    for i = 0, 15 do
    local cont = getcontainer(i)
    for j = 1, cont.itemcount do
    local info = iteminfo(cont.items[j].id)
    if info.iscontainer then
    local findIndex = 0

    local contIN = getcontainer(info.name)
    --if not contIN.isopen then
    for _, v in pairs(backpacks) do
    if v.name == info.name then
    findIndex = v.index
    v.index = v.index + 1
    break
    end
    end
    --print(findIndex)
    openitem(info.name,cont,true,findIndex)
    --end
    end
    end
    end


    And here is other file file with temporary table (only for tests)
    backpacks = {
    {name = 'grey backpack',index = 1},
    {name = 'red backpack',index = 1},
    {name = 'brown backpack',index = 1},
    {name = 'camouflage backpack', index = 1}
    }


    Im still so far from solution, if someone have any idea could be nice for sharing with me
    @Raphael could you help here? I just want to sell all items from depot, I see 2 ways. First is try to sell all avaiable items from items.xml file, the second one is what Im trying to do. I need to open all containers from depot, then my persistent can count that

  2. #2
    Moderator Raphael's Avatar
    Join Date
    Dec 2013
    Location
    raphseller.com
    Posts
    2,437
    Reputation
    309
    Rep Power
    28
    You have to open the container before calling getcontainer() on it.

  3. #3
    Free User pedegie's Avatar
    Join Date
    Dec 2015
    Location
    Poland
    Posts
    264
    Reputation
    28
    Rep Power
    17
    @Raphael Ye you were right. Anyway when i do that i see i must change my mind. I cant open backpacks as new windows because of screen :


    So I have to open one by one in same window. Do you have any suggestions? I thinking about counting same colors backpacks, then I will know which one i need to open after higherwindows() if i get this on most inside. For example i have:



    1 brown backpack - > (2 blue bp, 3 red bp)
    ................................. |................ |
    ..........................4 blue bp..... (1 brown, 1 yelow)
    .............................. |
    ....................... (3 green, 2 red)
    ............................ |
    ........................... etc..


    My idea is when I open brown backpack, then i save amount of blue(2) and red(3) bp, next im going to the first blue bp(1) with 4 blue inside, then savying amount of these backpacks etc etc.. When there isnt any backpack inside, Im using higherwindows() and check which backpack was last opened, then opening the next one.

  4. #4
    Moderator Raphael's Avatar
    Join Date
    Dec 2013
    Location
    raphseller.com
    Posts
    2,437
    Reputation
    309
    Rep Power
    28
    Your best bet is to use recursion.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •