lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello
 
I've implemented Lua in my game engine ok.  I can call functions in Lua scripts and get Lua to call my c functions.  I'm having trouble figuring out the way forward from there.  I've checked the web and the Lua manuals but can't seem to find a guide on how to implement systems.  All the tutorials I've looked at just give you hand on getting it implemented and then calling dofile.  Moving on from there to a safe system with lots of scripts running together seems like a different world.
 
I'd like to have my game ai (it's a shoot em up) running as scripts.  I've figured what I want to do is use coroutines.  I've looked them and got a handle on how they work from the lua script side but how does that tie up with the C side?  What's the best way of calling scripts?  wouldn't dofile be a bad idea in game?  if not dostring?
 
At the moment I'm just working towards having 2 simple scripts under the lines of...

-- this is one lua script running
while (true)
{
     DisplayText( "hello world", 10, 10 );
     Wait(100);
     DisplayText( "i've just waited a bit", 10, 10 );
     Wait(100);
}
 
and a seperate .lua file with...
 

-- this is another lua script running
while (true)
{
     DisplayText( "I'm just waiting until prompted", 600, 10 );
     Wait();
     DisplayText( "the c code moved this routine on", 600, 10 );
     Wait(100);
}
Any ideas on how this is done? 
 
Thanks very much!
 
Scott