Signup Now
Results 1 to 4 of 4
  1. #1
    Moderator mistgun's Avatar
    Join Date
    Dec 2013
    Location
    Lodz, Poland
    Posts
    1,821
    Reputation
    220
    Rep Power
    26

    How to get item position on ground?

    As title says, how can i get specified item position on ground?

  2. #2
    Free User jakub's Avatar
    Join Date
    Dec 2013
    Location
    Poland
    Posts
    132
    Reputation
    32
    Rep Power
    21
    Iterate through all sqms and all items on floor untill you find, then break.
    Example which consider only topitems (I am not sure about tibia screen width and height but it seems to be ok):
    Code:
    auto(10)
    local rx
    local ry
    local founditem = false
    for x=-8,8 do for y=-7,7 do           
     if topitem($posx+x, $posy+y, $posz).id == 3031 then
        founditem = true
        rx = x
        ry = y
        goto done
     end
    end end
    ::done::
    if founditem then
        print('found item on:', rx, ry)
    end
    Result is a relative position.
    Last edited by jakub; 12-24-2013 at 04:06 PM.

  3. #3
    Administrator Lucas Terra's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    2,202
    Reputation
    180
    Rep Power
    10
    You can always go with something more complex, of course.

    This function will return a pos x, y, z if the item was found at any position (not only on top) of your screen. And it will return 0, 0, 0 if the item was not found.
    function finditem(itemid)
    for i = -8, 9 do
    for j = -6, 7 do
    local tile = gettile($posx + i, $posy + j, $posz)

    for k = 1, tile.itemcount do
    if tile.item[k].id == itemid then
    return $posx + i, $posy + j, $posz
    end
    end
    end
    end

    return 0, 0, 0
    end

  4. #4
    Moderator mistgun's Avatar
    Join Date
    Dec 2013
    Location
    Lodz, Poland
    Posts
    1,821
    Reputation
    220
    Rep Power
    26
    Thank You guys! I will test it :P

 

 

Posting Permissions

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