I've checked in some changes to the script-compiler branch.
I have added an action for scripts to set the planet info entries for any galaxy/planet rather than the current one. I found this useful when I wanted to change the state of a different planet in a script based on actions in the current one.
Universe::expandDescription now expands _string, _number, and _bool functions if they are enclosed in []. You can optionally pass a script local variable dictionary in and have script local variables expanded if they are enclosed in []. I have done this so that the original signature of the method is maintained to existing code sees no difference in regards to locals, although the functions will now get expanded if enclosed in []. Note that given the behaviour of expandDescription, anything that looks like a function or local var passed in now would have to be a mistake because the only valid expansion expressions in the current code are mission variables, commander variables, and numbers.
Script local variables can be checked in conditions.
scriptAction now calls expandDescription before calling the action. The action word itself isn't pased in but all action arguments are. Yes, even the target of an assignment. So if you are determined to do:
and local_x has a value of "mission_y", then the action that gets executed is:
So you can do things like:
Code: Select all
set: local_x [d100_number]
set: local y [d100_number]
add: local_x [local_y]
In the add action, local_x isn't enclosed in square brackets because that would make it be expanded, which you don't want.
Now, script and local vars, and functions, are ALWAYS expanded in conditions, and must not be surrounded by []. This is a bit inconsistent, but having to put them in [] in conditions would make scripts less readable (and I'm trying to improve that aspect!) and also annoying to type. So I'm happy to live with that one.
I'll post the oolite.exe on the Oolite-PC site for anyone that wants to try it. Just back up your current .exe and replace it with this one to try it, then go the other way to put the original back.