So I’ve started learning Lua with the intention of replacing ASL with a language other people might be able to use. Now that Lua is a standard package with Free Pascal it’s a natural choice for a scripting language, and it’s been no problem to set up and use… by itself, at least. My big problem is trying to figure out how to incorporate it into GearHead.
I can see two obvious ways to do this. First, I could do things the way I already do them and attach individual Lua scripts to every gear that needs them. When the time comes to trigger a script then the scripts for that gear will be sent to the stack and the proper function invoked. One problem I can see with this is that function declarations from previous gears might be hanging around in the Lua environment; suppose I want to process a “START” trigger, and the current gear doesn’t have a “START” script but the gear which came before it did. Wouldn’t this execute the previous gear’s START function a second time, since it hasn’t been overwritten?
An alternate way to do things would be to make each script-holding gear a Lua object and access their scripts as methods. In this case, how do I deal with having parallel representations of each gear? When a gear is created/disposed of I’d have to create/dispose the parallel Lua object, which seems like a pain in the arse… though, I guess, no more a pain in the arse than creating/disposing of attached attributes.
Whichever way the scripting is done, there’s one more very big problem which I need to address: How to merge scripts together. GH’s plot creator takes multiple component scripts and combines them into a single script. The general rule is that for any given trigger the newly added effect happens first, then the previous effects are called. ASL was designed with this in mind but I have no idea how to do it with a language such as Lua.