CarRepairer wrote:No conversion tool yet?
Not a 'run and forget about' one. Lurker has written some prototype thing, which, combined with some common sense, copy paste and search and replace can speed up manual conversion a bit.
I don't know whether he has any plans to continue on this.
Argh wrote:1. Are there any clear-cut performance advantages / disadvantages?
I haven't done accurate realistic measurements yet (well I did some but I forgot the results <_<), but some preliminary testing suggested Lua in general is a bit faster then COB.
Argh wrote:I can see the flexibility of keeping logic all in one language, so I'm wondering if there are any serious tradeoffs. But I'd happily trade BOS for Lua if there aren't any serious penalties, conversion looks like it's mainly going to be some grep and minor alterations.
That's what the Lua script lurker has worked on does.
The main advantages over BOS/COB are that Lua is a more mature language with more data types then just integers, and that you can use all normal (synced) Lua call-outs easily from within Lua unit scripts now (less need for ugly hacks to interface synced Lua code with unit scripts.)
Argh wrote:2. I see that Killed() has a number of areas which are still WIP (explode, etc.). Is it possible that this will entail greater flexibility in this area in the future?
If I recall correctly the only thing missing is symbolic constants for the flags to explode.
Argh wrote:3. If the coordinate system is made to match, just keep in mind that that will make 1:1 quick conversions considerably harder. Perhaps make that a flag set on Create?
No, making it configurable would just complicate code reuse between different scripts (and games).
The conversion isn't that much harder; you'll just have to invert the destination for moves along the X axis, and starting at the next release invert the destination angle/speed for turns/spins around the Z axis.
Argh wrote:4. The equivalents to the shorthand [] and <> would probably be a good idea.
Special operators are a no go IMO since this requires quite some modification of the Lua parser.
It's easy however to define a function on the top of the script, or in the 'header' file that is automatically prepended to each script. (see gamedata/unit_script_header.lua in springcontent.sdz)
Argh wrote:5. How do we do #includes? Just VFS.Include(ANIMATION_LOCATION .. 'standard_commands.lua',nil,VFSMODE)?
That is one way, however this means everytime a unit which uses this script is created the file has to be decompressed and parsed.
In the Spring: 1944 mutator I've included another gadget that simply runs all *.lua files in 'script/library' (default directory prone to change, because it conflicts with adding recursively scanning for unit scripts in 'scripts' [like what was added for unitDefs in 0.80])
I've started the convention these *.lua scripts put their unit script library function into the 'GG.UnitScript' table.
Since unit scripts have access to the GG table, they can then easily refer to this using e.g. GG.UnitScript.MyUtilityFunction()
Argh wrote:6. Can we send animation commands to Features with this method?
Nope, that's unrelated to this.
imbaczek wrote:Argh wrote:
4. The equivalents to the shorthand [] and <> would probably be a good idea.
ideally, [] and <> won't even make sense. all speeds and angles should be given in their respective units depending on the function they're passed to. [] and <> were needed because BOS can't handle floats; lua, OTOH, can't really handle integers (everything is a double precision float).
note that i don't know how Tobi decided to implement all this.
Argh wrote:True, true, and I'd certainly approve if "Move(unitID, Piece, Axis, Distance)" was just automatically converted into linear units with the proper multiplier.
Move takes coordinates simply in elmos; Turn and Spin take angles in radians, angular speeds in radians per second, and angular acceleration in radians per second per frame. (Should I change this to radians per square second?)
Argh wrote:Gotta remember though: UpSpring is our primary tool for posing everything, as it already uses BOS units of linear / rotational coordinates and measurement. This is unlikely to change.
That's why I'm fairly dubious about "correcting" the rotation system (unless UpSpring is also updated), and why a need for straightforward conversion of [1] to "1" is necessary.
Good point about UpSpring, however it doesn't convince me yet to keep using inconsistent coordinate systems forever. (It is inconsistent because now, in COB, rotations around the x-axis and z-axis are left-handed and rotations around the y-axis are right handed, and the x-axis is mirrored compared to Spring's world csys.)
Argh wrote:Another question: if a Unit has a Lua script, does it still run a BOS thread?
No.
Argh wrote:And if we want to terminate a Lua animation thread, but not kill the Unit, can we do that, without hosing the entire system? If not, that would be a good idea- put a way to do a break in, so that we can do operations during Create(), halt the thread and not touch its other elements, and only run an animation script through Lua Callins elsewhere.
Not sure what you are asking here. In the framework I implemented Signal and SetSignalMask which you can use to 'kill' an animation thread without killing the unit, just like in COB.
Argh wrote:That would be a major step forward, if I could quit running so much overhead "Units" that aren't actually doing anything unless they die. As most of you Dev people know, this would probably have a pretty big performance savings in World Builder, where "empty threads" for hundreds of objects and their callins still have a non-trivial CPU cost every frame. If I can exit the Lua animation code, and BOS no longer imposes any overhead (i.e., by using this I can "opt out" of BOS, finally) then I can see some very significant cost savings- Units without sight radii would perform almost as well as Features.
If you don't need to do any animation, you don't have to run any animation threads. This is the same as in COB.
Similarly a sleeping or waiting thread doesn't use any CPU, only a bit of memory. This is also the same as in COB.
Also just like in COB functions that aren't implemented aren't called, and as such do not use any CPU. This also didn't change.
Argh wrote:Which BOS constants do *not* have 1:1 equivalents in Lua? I.E., are the mathematical / operation constants, such as get PIECE_XZ, going to be replicated?
Spring.UnitScript.GetUnitValue and Spring.UnitScript.SetUnitValue (same as Spring.GetUnitCOBValue and Spring.SetUnitCOBValue) are available..
I also added a global COB table that contains the COB '#defines'. (e.g. COB.ACTIVATION, COB.BUILD_PERCENT_LEFT, etc.)