I am just wondering if there is any other way to remove a value from a table not using table.remove().
I haven't really played with anything but here was my thought, create a new table and transfer those values to that table and get rid of it later on.
local function remove(tab, index) local placeholder = {} for i,v in pairs(tab) do if i == index then table.insert(placeholder, v) -- Needs to use table.remove to remove the selected value end end end
Problem is there is no way to transfer a value like that without using table.remove() .
You can do this:
table = {1, 2, 3 } -- set a table that there have 1, 2, 3 values. newtable = { } -- create a new table newtable.insert = table[1] -- insert the table's first value inside the new table newtable.insert = table[2] -- insert the table's second value into the new table table = nil -- set the table to nil, so the table might clear print("table's third value have been removed")
Simply, it works like this. My script is not 100% correct, this is just a concept for you. If this helped you or anything, please upvote! I don't like to say it, but it helps a lot! Thanks :D
Like herrtt is saying, you could just set the value of the slots in your table to nil.
--placeholder is your table. Let's say you have these values in your table: {1, banana, 64, $, 9} --If you want to get rid of banana, you would use placeholder[2] = nil --You use the 2 because banana is the second value in the table. Now your table looks like this: {1, nil, 64, $, 9} --Remember that nil is not a string value itself; it's the absence of a value.
Hope I helped, and happy coding!