Hey All,
First post here after recently picking up and playing with pico-8 (humble bundle). It's rather brilliant I have to say!
I have only been playing around with coding for a couple of months and remain very much a novice, and this is my first time using lua with pico-8.
My question is regarding tables of tables (objects I am spawning in my game), and the deletion of those objects...
Let's say we have the following little program which spawns 5 THINGS, gives them unique names, and then adds them to the list a{}. We then delete the item with NAME=3, and then print some output...
a = {}
for i=1,5 do
local thing = {}
thing.name = i
add(a,thing)
end
for thing in all(a) do
if thing.name == 3 then
del(a,thing)
end
end
for thing in all(a) do
print(thing.name)
end
print("# = "..#a)
print(a[3])
|
Output is: 1, 2, 4, 5, # = 4, TABLE
This works fine, and is the standard practice I have been using to remove objects from the master table.
However, let's say I already know which item on the main table (a) that I want to delete by its index, say the third item... i.e. a[3]






3 comments