local list = {}
table.insert(list,3,"soy el tercero")
table.insert(list,2,"soy el segundo")
table.insert(list,1,"soy el primero")
table.remove(list,2)
print(list)
If you don’t care about the order of things, you can use a dictionary instead and point directly to what you need since you’re using strings:
local list = {[" value1"] = true, [" value2"] = true, [" value3"] = true, value = true} -->value is the same as ["value"]
Then you can do some nifty things like checking if it exists without any loops based off of its value and NOT a numbered index:
local function dictionaryUsage(value)
if list[value] then
print("value exists, so let's delete it!")
list[value] = nil
else
print("value doesn't exist, so let's create it!")
list[value] = true
end
end
dictionaryUsage("blah")
print(list) --> "blah" is added to the dictionary
dictionaryUsage(" value1")
print(list) --> " value1" is removed from the dictionary
I almost exclusively use dictionaries because of their versatility/speed; especially when dealing with varying values. The only time I ever use an incremented indexed table is when the order matters, but that’s not nearly as common