Jump to content

Small Question... Fast answer please.


xScatta

Recommended Posts

Hey all i have a question.

So i put things in table like that

  
table = {vehicle, player1, vehicle8, player9} 
-- so i want to do something LIKE that 
table.remove(table,vehicle8) 
-- btw theres so many things in table this is only example 

And i don't know how to make something like this BUT working. Anyone help please.

Or if it is possible to GET position of element in table.

Link to comment
table.remove uses table index, so instead of 'vehicle8' you would need to use '3'.

But if you don't know the index of the value you want to remove, then loop through the table to find it.

(note: if you use "table" as a variable name it overwrites the global "table", so you can't use table.remove and other table functions.)

for i, v in ipairs ( t ) do 
    if v == vehicle8 then 
        table.remove ( t, i ) 
    end 
end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...