You can't call a table (and doing this in Lua will cause you to receive an error). You're thinking of something different.
for i = #enemy - This is the initial statement of the for loop, declaring the initial value of i (#enemy means the total number of items in the enemy table). The 1 and -1 mean "Keep going through each value of the table with i being one less each time, until we get to 1."
WolfNinja2 wrote:and enemy.remove is that just checking if v.remove is true?
Yes. Your objects will have a remove variable, initially set to false. Set it to true when you want to remove the object. This is because you don't want to actually remove the objects while you're still processing their logic (as this would cause a lot of problems). Instead, after running their logic you run through the list to see which objects need to be removed, and then remove those.
It's always best to ask questions and understand the topic we're trying to teach you about, even if it does take lots of questions. That way you can learn how to do it yourself rather than coming back here all the time.
The code I was posting did what Dattorz said, but here's the reason why I was using the reverse loop. When you remove tables in a pairs loop there's a chance you can break the loop and stop things from properly being removed. That way you can always be sure the things are being fully removed from the table.
Thanks Guys but it is STILL not working :/ here is the game, to skip to the level where enemy's are, uncomment line 73 and comment in line 69 of main.lua :/
Qcode wrote:Don't know what you're talking about now. For me when you shoot the enemies they get removed. Is that not the intended effect, if so, what is?
Oh....well maybe I should have tested more than once..... THANKS!!!