xScatta Posted January 6, 2014 Posted January 6, 2014 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. It's fine to celebrate success but it is more important to heed the lessons of failure.
Castillo Posted January 6, 2014 Posted January 6, 2014 table.remove uses table index, so instead of 'vehicle8' you would need to use '3'. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
csiguusz Posted January 6, 2014 Posted January 6, 2014 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 Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003
Castillo Posted January 6, 2014 Posted January 6, 2014 You can also store the index in another table to avoid looping. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now