[09 Jan 2010] What about repeated table creations in different pages in designer.

Contains all messages from the Hollywood mailing list between 01/2006 and 08/2012
Locked
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

[09 Jan 2010] What about repeated table creations in different pages in designer.

Post by Bugala »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 09 Jan 2010 03:00:11 -0000

This didnt come to my mind earlier, but now that it came i wonder do i need to alter code.

Thing is, i have missions in my game.

Each mission uses same page and it just sends string mission to know which mission.bin to know ie "mission"..mission..".bin" could be mission1.bin if mission=1 which is determined in previous page on mission player chooses.

Now since i was making the engine basically all the way to this point, it never occured to me that there might come pronblem from table creation.

for thing is, in this mission page, it creates several tables in way of:

Code: Select all

enemy={}
snowball={}
this of course wasnt problem when i was still testing and making it with cubic IDe and each time starting mission from fresh.

But in game in practice, you play mission, finish it, choose new mission and it goes to that same mission page again.

And this i now wonder if what happend when same table is created again.

For now for example that enemy={} is done when you first time go to first mission. Along the mission there will come lots of stuff to that enemy like enemy[wave][group][id].x

So theres coming plenty of stuff to that table.

When mission ends, theres no worry yet, but when you go to second mission and it starts next mission, then what happens at part when comes the line:

Code: Select all

enemy={}
again?

Does it ignore that command? Does it create whole new table and destroy all the old stuff away, that if size of enemy table was say, enemy[5][10][3] its size would now be only one empty table and all those old stuff are gone?

As far as i tested with designer, it at least on my short test didnt give me any trouble, but i just wonder if there is some bomb laying there waiting for me.

Say i decide to check next free enemy and go through it with command RawGet(), then it gives me result of next free being enemy[5][10][4] when real answer would be enemy[0]?

For basically i can do those table creation parts elsewhere or add table destroyers or something to end of level code, but it would just be quite much work to do that all at this point, plus it would make harder testing engine part separately.
Robin
Posts: 16
Joined: Sun Feb 14, 2010 6:29 pm

[09 Jan 2010] Re: What about repeated table creations in different pages in designer.

Post by Robin »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 9 Jan 2010 13:13:18 +0100 (CET)

Hi,
enemy={}
The {} assigns an empty table to enemy. So with each call of this line you "forget" what was stored there before.
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

[09 Jan 2010] Re: What about repeated table creations in different pages in designer.

Post by Bugala »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 09 Jan 2010 13:05:11 -0000
The {} assigns an empty table to enemy. So with each call of this line you "forget" what was stored there before.
Ha, how stupid of me, of course it works that way. its same situation of course as table1=table2.

Thanks from reply. Makes me much happier to know that i dont need to fix that code.
Locked