As title says, how can i get specified item position on ground? :)
Printable View
As title says, how can i get specified item position on ground? :)
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):
Result is a relative position.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
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
Thank You guys! I will test it :P