Topic: Question about LUA scripts

Hello,

In general, what is the best way to organize them ?

Cause i'm over 500 lines for just some graphics and pretty basic movement / ennemy respawn system,
spending more time scrolling up side down into a variable labyrinth trying to fix small things rather than doing usefull
stuff for the game. This is slowing me as hell, any tips are (more than) welcome !

Here's the code i'm working on : http://dl.dropbox.com/u/19970067/Questions/Skyline.lua
Its pretty basic and cowboy coded however i better ask now before i got burrowed under variables.

Last edited by Vegas (2011-10-08 20:43:11)

Re: Question about LUA scripts

Hi,
I'll have a look, for now I will say that the very important thing you need to do is using
functions to create generic stuff and reuse code on maximum. For exemple, when you see
that you are doing something more than one, make a function and call the function.

And for your variable, try to pack it in class or tables.

You can also cut your script and distribute it in multiple files for better clarity
(for example you can put all the functions in a separate lua file)

But I should say that the best way to make a game is to create all the generic and consuming stuff
as c++ behavior, and then do the logic in lua. Because once a behavior is done, you just have to put it on an object
and the time you finally gain is uge.

Re: Question about LUA scripts

Perfect smile

Making functions and splitting files will greatly help, made some test already,
so far everything is working fine!

Very big thanks wink