Skip to content

Consider using LUS variadic functions #5765

Description

@sprunk

Since a year or two the engine provides variadic versions of common LUS functions like Turn, Move etc which is meant to save the runtime overhead of multiple function calls. Like this:

- Move(foo, x_axis, 1, 2)
- Move(bar, y_axis, 3)
- Move(baz, z_axis, 6, 7)
+ MultiMove(foo, x_axis, 1, 2,
+           bar, y_axis, 3, nil,
+           baz, z_axis, 6, 7)

The basic way to apply this is to of course edit the script files. The other would be to keep scripts as-is and instead modify the LUS gadget to automatically do some string preprocessing at init.

Caveats:

  • Turn is actually wrapped in the LUS gadget and would either need support there or be exempt.
  • keep in mind the 4th 'speed' arg can be nil, like in the example above, which can ruin naive parsing.
  • the perf gains are apparently quite low, so even though we get them "for free" this is a low efficiency task. Proof of concept and a fresh measurement (on a unit with lots of adjacent function calls, say Dirtbag) would be good.
  • this applies to the usuals (Move, Turn, Spin, Scale) but also Explode (!), SetPieceVisibility, and StopSpin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendStuff that makes code easier to work with, without affecting the end userskill: LuaProgramming in Lua.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions