Scriptability in Lua someday?

I think adding a “scripting” ability for people to program the behavior of their ships would be Very Cool. I understand it might be way out of scope for the first release (or second …), but I think this could take GSB from just “really, really cool” all the way to “eleven”.

What I’m thinking of is something like Lua as a scripting language, and ultimately, something like Robocode in terms of programming API -

The first level of programmability would be to just do navigation by programming (I can imagine some ships holding back until fleet strength is below x%, then swooping in, or writing “hunter-killer” programs that target specific ships). More advanced stuff would be to control energy management (“all power to the shields!” or more likely “all power to the forward phaser banks!”).

I could imagine that this could be a module that you plug in to a ship. The module could be for programmability at all, or for a specific program, not sure what makes more sense.

Among the challenges to doing this include performance (I can imagine that individually programmed fighters, in the thousands, could pose a significant processing overhead), but that could also be addressed with some kind of CPU limiter, or scheduling frequency adjustment. Of course it’ll be tricky defining the API, and folks will squeal a lot if their favorite program breaks after a system update, but “them’s the breaks,” right?

[size=85](apologies for promoting this to a topic of its own, but I think it got lost in the earlier thread about modding features)

It’s unlikely to see this implemented any time soon. External scripting languages are sloooow in comparison with the very very optimised code used to do stuff like AI decision making in GSB. There are a lot of ships, making lots of decisions on a lot of criteria, and it’s just much much faster to have some optimised C++ do this than parse an external language, even if those scripts can be converted into their own faster compiled code.
Thats not to say that the game could not have more capabilities in that area, it’s just unlikely to be able to interface with it using 3rd party code.

(possibly) the best way would be to run a seperate thread that is dealing with scripted AI - and this communicates with the main game engine as/when. there would be a small amount of decision lag, but that’s to be expected due to thinking time. (well, unless you have a race of soul-less thinking engines).

with this model, you could update the AI thread on an event basis for things happening, and (relatively) infrequently for the ship location/status matrix. it could then chunter away in its own thread processing whatever the mad modder wanted and send “move there” “attack that(lasers),them(missiles)” orders back into the game engine.

I believe you when you say that something like Lua wouldn’t be fast enough (at least on today’s ‘pokey’ processors) to keep up with the rest of GSB. On the other hand, we are getting more and more cores these days, so maybe it’s not totally out of the question for all time.

Another approach, taken by the “Impromptu” livecoding system, would be to compile the scripted extensions at load time, using something like LLVM, into very efficient code. Impromptu is using this technique to allow people to write real-time DSP code in Lisp, of all things!

Again, I’m not saying I expect this, I just think it would be totally cool.