• 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 Item table position

felzan

Caos manager
Joined
Dec 19, 2009
Messages
38
Reaction score
8
Is there any way to find out all positions of an item? (like table of positions)

I want to create bushes around each tree (2701) on start server.

like this: id:tablePosition(index)
ty
 
Code:
function AnIndexOf(t,val)
    for k,v in ipairs(t) do
        if v == val then return k end
    end
end

print(AnIndexOf(table, 2701))

table.remove(table, AnIndexOf(table, 2701))
 
Last edited:
Code:
function AnIndexOf(t,val)
    for k,v in ipairs(t) do
        if v == val then return k end
    end
end

print(AnIndexOf(table, 2701))

table.remove(table, AnIndexOf(table, 2701))

Or... just use the built in isInArray(array, target)
 
Back
Top