Sharing Lua States
Posted: Sun Apr 10, 2011 7:22 pm
Hey all. This is my first post here, but I've been following the AiGD series for quite some time.
A guy I know from another forum (if any of you have ever heard of a game called Uplink by Introversion, then this guy worked on probably the biggest mod of the game, called Onlink; he also recently bought me a shiny new GTX 580 as a gift) started work on a cross-platform 2D game engine capable of using a variety of different backends for it's different parts (SDL/OpenGL/Direct3D for graphics, SDL/OpenAL for sound, etc.). I've been interested in game development for quite some time and just recently got really serious with it. My first goal is to write a better Minecraft client (because the current Java implementation uses WAY too much resources). In order to do that, I've started converting this engine from 2D to 3D.
Anyways, I've just recently learned more about Lua. This engine already included the lua library, the engine itself did not wrap around it any way, however. I took it upon myself to add a Scripting system, and so far I've gotten a basic Lua subsystem up capable of running scripts with a single call.
The way I have the system set up is pretty simple, create a new state in the constructor and destroy that state in the destructor.
The scripting object is initialized when the engine is started and destroyed when the engine exits. In that sense, all scripts ran share the same state, meaning I can declare variable 'hello' in one script and print it's value in another, which I find handy. Is this the optimal way of doing things or might there be underlying issues that I haven't accounted for?
A guy I know from another forum (if any of you have ever heard of a game called Uplink by Introversion, then this guy worked on probably the biggest mod of the game, called Onlink; he also recently bought me a shiny new GTX 580 as a gift) started work on a cross-platform 2D game engine capable of using a variety of different backends for it's different parts (SDL/OpenGL/Direct3D for graphics, SDL/OpenAL for sound, etc.). I've been interested in game development for quite some time and just recently got really serious with it. My first goal is to write a better Minecraft client (because the current Java implementation uses WAY too much resources). In order to do that, I've started converting this engine from 2D to 3D.
Anyways, I've just recently learned more about Lua. This engine already included the lua library, the engine itself did not wrap around it any way, however. I took it upon myself to add a Scripting system, and so far I've gotten a basic Lua subsystem up capable of running scripts with a single call.
The way I have the system set up is pretty simple, create a new state in the constructor and destroy that state in the destructor.
The scripting object is initialized when the engine is started and destroyed when the engine exits. In that sense, all scripts ran share the same state, meaning I can declare variable 'hello' in one script and print it's value in another, which I find handy. Is this the optimal way of doing things or might there be underlying issues that I haven't accounted for?