Results 1 to 5 of 5

Thread: Help with 'Container Class'

  1. #1
    Focus Group mexicowss's Avatar
    Join Date
    May 2012
    Location
    Brasil
    Posts
    440
    Mentioned
    20 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    59 Post(s)
    Reputation
    128
    Rep Power
    6

    Help with 'Container Class'

    Well, there i was doing a script for Barbarian Test+ Ice Islands quest and everything was running well, then i arrived the part of pushing mammoth.

    The problem i found is that we need to use at least 3 cup of any acohol to be able to push mamoth, BUT,
    The IDs of all mugs is always 2880 no matter if its filled or empty, so when i tried to make bot take me drunk, it kept using the same cup, that was already used.

    So i gone for a search on var and functions and i find this:
    2.7 Container Class



    2.7.1 Container Information

    getcontainer(string/int container) [pointer]: Returns the data structure of a container. You could index container with an int value starting from 0 to specify which container you want to access.
    .id [int]: Returns the item id of the container window.
    .index [int]: Returns the index of the container window.
    .maxslots [int]: Returns the maximum count of items that can be stored in the container.
    .name [string]: Returns the name of the container window.
    .open [string]: Returns true if the container is open and false otherwise. Always check if a container is open before accessing it's other elements because values stay in memory even after the container has been closed.
    .usedslots [int]: Returns the count of items in the container.
    .items [userdata]: Returns the data structure for an item in the container. You must index item with an int value starting from 1 to specify which item you want to access.
    .count [int]: Returns the amount of the item.
    .id [int]: Returns the id of the item.
    Im kinda confused because i dont know how to index this item and use it inside a useitemon(item,posx,posy,poz).

    i've tried different ways like useitemon(getcontainer(0).items(1), posx,posxy,posz) but it obviously wrong.

    Can anybody send me and example?
    Like use item on slot 1 from container 0 (mainbp) in some position?

    Thanks in advance
    Last edited by mexicowss; 09-26-2013 at 10:53 AM.
    click the image below to see my thread.



  2. #2
    Normal User e k x's Avatar
    Join Date
    Sep 2013
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    2 Post(s)
    Reputation
    18
    Rep Power
    4
    useitemontarget(2880, id)

    keep in mind that indexing means using [number], when you're using () you're trying to call function.

    This is how you should use it:

    Code:
    local cont = getcontainer(0)
    local items = cont.items
    useitemon(items[0].id, x, y, z)
    It starts from 0 and goes for 19, which means all 20 items a container can have. Except for bp of holding and other different backpacks.

  3. #3
    Focus Group mexicowss's Avatar
    Join Date
    May 2012
    Location
    Brasil
    Posts
    440
    Mentioned
    20 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    59 Post(s)
    Reputation
    128
    Rep Power
    6
    Quote Originally Posted by e k x View Post
    useitemontarget(2880, id)

    keep in mind that indexing means using [number], when you're using () you're trying to call function.

    This is how you should use it:

    Code:
    local cont = getcontainer(0)
    local items = cont.items
    useitemon(items[0].id, x, y, z)
    It starts from 0 and goes for 19, which means all 20 items a container can have. Except for bp of holding and other different backpacks.

    Thank you sir for the simple and complete explanation. i was messing simple parameters , so rookie hahaha.
    It works like a gold.
    Now i'll finish the script and release it for free very soon.
    Last edited by mexicowss; 09-26-2013 at 10:53 AM.
    click the image below to see my thread.



  4. #4
    Normal User e k x's Avatar
    Join Date
    Sep 2013
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    2 Post(s)
    Reputation
    18
    Rep Power
    4
    thanks for the reply and script, it's a very boring quest to do :P, your script will come in handy

  5. #5
    Focus Group mexicowss's Avatar
    Join Date
    May 2012
    Location
    Brasil
    Posts
    440
    Mentioned
    20 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    59 Post(s)
    Reputation
    128
    Rep Power
    6
    There you go , barbarian test is done, but i'm to lazy to do ice islands now, btw just checked theres already one released, the owner is Umpii, i just sent a PM asking if i can merge both scripts if he dont mind.

    Link: http://www.tibiaibot.com/forum/showt...l=1#post334339
    click the image below to see my thread.



Posting Permissions

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