Hey folks! First post, here.
I just started learning Lua this summer, and the use of tables has been a big hurdle to me. I seem to have the basic concept worked out, but something really weird is happening to my one project.
Long story short, I'm making a racing game that is fairly code-intensive when it comes to the graphics. It was working just fine, until the other day when I started working on a level-select feature. I changed one of the level parameters from a solo variable to a part of a table, so that I'd be able to group the various parameters into nested tables and swap them with a simple level index, but suddenly, the performance took a nose-dive. I don't mean dropped frames, I mean it slowed down to a fraction of the acceptable frame rate, seemingly down to 5 frames a second or less.
I changed that one variable back to a standalone variable, performance jumped back to normal. Changed it back to an entry in a table, and the game slogged back down to a few frames a second.
I know there's a lot I still don't know about using tables, but does anyone know of any hard limit that would abruptly cause performance to suffer this drastically? All I changed was this:
(in _init:) stage={addr=0} spire=1 (in _draw:) spr(5,64+rel_x,56-(spire*8)) for y=1,spire do spr(6,64+rel_x,64-(y*8)) end |
Vs:
(in _init:) stage={addr=0,spire=1} (in _draw:) spr(5,64+rel_x,56-(stage.spire*8)) for y=1,stage.spire do spr(6,64+rel_x,64-(y*8)) end |
Any help would be muchly, muchly appreciated. Thanks!