• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Check Items on ground

G4BB3R

New Member
Joined
Jul 23, 2010
Messages
80
Reaction score
4
Hello.
I am trying to loop through all items in the ground (except floor)
But using the script gives some console errors because it loop at non existent items.
Code:
  for stack = 1, 255 do
    if getThingFromPos({x = a.x, y = a.y, z = a.z, stackpos = stack}).uid > 0 then
    --[...]
    end
  end


# Question 2: What function I can use instead of:
getTileItemById(pos, id)
If I am searching for any item that is in a table.

Example:
getTileItemById({x = 1232, y = 2322, z = 8}, {3031, 3032, 3033, 8877})


Thanks!
 
Last edited:
You mean go one-by-one?

Lua:
table = {3031, 3032, 3033, 8877}
for i=1,#table do
local find = getTileItemById({x = 1232, y = 2322, z = 8}, table[i])
if find ~= 0 then
dotdotdot

Like that?
 
Ok, thanks.. I think I will make a function similar to your code:
getTileItemByTable(pos, item_id_table)

And about the item table in the ground ?
Using a getThingFromPos with stack from 1 to 255, give the wrong sequence of items :c
How to loop through the items avoiding creatures and in the correct stack sequence ?


peace
 
Last edited:
Maybe loop backwards:
Lua:
for i = 255, 1, -1 do
    local thing = getThingFromPos(.....)
 -- Also check if not isCreature(thing.uid) then
end
 
I am having problem with it :/
Imagine I am trying to teleport X items in the same stack to walk in a route...
(hard to explain what it will be in the future)

Looping 1,255 and inserting in a table and removing from the map and after re-creating in the new pos
Code:
looping all the ways makes the stack sequence changes
1,255 / 1, #items      wrong
1,255 / #items, 1      wrong
255,1 / 1, #items      wrong
255,1 / #items, 1      wrong too :c

What is happening:
Code:
Before: table, box, fish
After:   fish, table, box
or (depending the way I loop)
Code:
Before: table, box, fish
After:   box, table, fish
ps.: I am doing the correct loop syntax, the problem is not here.

Can someone give me a help? <3
 
Back
Top