Original Post
Just getting Lua integrated into my game at the moment, is going pretty great, got all my utility functions sorted, started on my interface to the engine, and ported over vectors and other such data structures to work inside Lua. I have one problem left - Loading/unloading of multiple scripts. At first glance I figured it would be easy - start of a mission load in scripts for entities that exist, the mission script, and what not else so all functions are availible to the game. I can not seem to load up multiple scripts in this way, atleast trying to use luaL_loadfile multiple times does not work, and I have failed to find anything on the internet to point me in the right direction so far - severe lack of Lua stuff out there. I considered multiple VMs, one per entity as Silvo suggested in another post, as this would mean I wouldn't need to mess about too much with metatables, or even object orientation in Lua at all. But this would mean I need to expose all the functionality I would like every time a lua_State is created, which I'm sure would be noticable performance wise. Has anyone else tried to do this sort of thing? Essentially I would like all entities that can exist to have their own script defining its behavoir, so dropping new entities/triggers into the world isn't a hard job. Communication between entities and the gui is done via a string based message system inside the game engine itself, which allows the gui to send commands to entities, triggerable brushes in the world to broadcast messages to all entities, so on. Thanks. [Edited by - Richy2k on February 17, 2007 9:30:01 AM]