Big Bucket Software you like to use
Lua Process and Hurdles
March 8th, 2006

Ok, well things are going very well. I tidied up my sandbox last night and checked everything in. I was able to go around blowing classes away that are now managed by Lua. The coolest little change I made last night was to add this to the script:

function some_callback()
    dennis:queueSpeech("Wow, it works!")

Admittedly, the registration of the callback happened in C++, but it would be very easy to make the registration scriptable. Now for the hurdle. I’ll try my best to explain this clearly…

The pipeline of operations is this:

  1. Main loop updates all objects
  2. Signals are emitted
  3. Any Slots/Callbacks do their processing

That obviously occurs over and over, until the user exits. An example of a signal might be that the lightswitch was turned on. Assuming that this event was slotted to a script called some_callback, that callback needs to return before we can get back to the main loop. Therefore, it doesn’t seem to be easy to implement a waitFor(x) type function. For example, I can’t figure out how to do this:

function some_callback()
    dennis:queueSpeech("Looks like a lightswitch")
    bob:walkTo(dennis:x() - 10, dennis:y())
    bob:queueSpeech("I agree")

Problem is, the script isn’t running in a seperate thread. I would certainly prefer that it stay that way, but I’m not sure exactly how to achieve this. One idea, is that I make the waitFor function register a callback with isIdle, process the main loop continuously itself and unregister with isIdle when it receives the callback… somehow.

It’s all a bit messy and it’s certainly something I’m going to need to address.