Animation-LuaScripting: Difference between revisions

From Spring
Jump to navigationJump to search
Tobi (talk | contribs)
VFS.Include->include
Tobi (talk | contribs)
mNo edit summary
Line 41: Line 41:
* Link to article in piro's magazine
* Link to article in piro's magazine
* Coordinate system (axis, direction of rotation, picture)
* Coordinate system (axis, direction of rotation, picture)
* Library functions (plus the gadget)





Revision as of 11:34, 3 September 2009

Getting started

Setup

Lua unit animation is implemented partially in the engine, and partially in a Lua gadget which is shipped with Spring in springcontent.sdz. By default, this gadget is not loaded, so a bit of setup is required to enable Lua unit scripts.

To enable Lua unit scripts, create a file LuaRules/Gadgets/unit_script.lua, and paste the following into it:

-- Enables Lua unit scripts by including the gadget from springcontent.sdz

-- Uncomment to override the directory which is scanned for *.lua unit scripts.
--UNITSCRIPT_DIR = "scripts/"

return include("LuaGadgets/Gadgets/unit_script.lua")

Now this is done, you can start putting *.lua files in your scripts/ folder.

Workflow

Lua has the major advantage over BOS/COB that you do not need to compile it, which can reduce the time to develop scripts quite a bit.

To save further time, do not restart Spring for each small change. Simply run Spring in an window so you can easily switch between your editor and Spring, and use /luarules reload to reload all Lua unit scripts.


Further reading


TODO

  • Conversion tool
  • Performance measurements
  • Advantages
  • Link to article in piro's magazine
  • Coordinate system (axis, direction of rotation, picture)