Animation-LuaScripting: Difference between revisions
Added some info how to edit and use. |
m →Setup: cross reference springcontent.sdz |
||
| Line 3: | Line 3: | ||
=== Setup === | === 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, gadget is not loaded, so a bit of setup is required to enable Lua unit scripts. (In some games, gadget is alredy activated, for example in Zero:k) | 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, gadget is not loaded, so a bit of setup is required to enable Lua unit scripts. (In some games, gadget is alredy activated, for example in Zero:k) | ||
To enable Lua unit scripts, create a file ''LuaRules/Gadgets/unit_script.lua'', and paste the following into it: | To enable Lua unit scripts, create a file ''LuaRules/Gadgets/unit_script.lua'', and paste the following into it: | ||
Revision as of 21:41, 26 November 2013
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, gadget is not loaded, so a bit of setup is required to enable Lua unit scripts. (In some games, gadget is alredy activated, for example in Zero:k)
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")
|
Also, do check whether your LuaRules/system.lua is up to date, if you copied this verbatim into your game. (Must be from a later date than 5 september 2009)
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 /cheat and /luarules reload to reload all Lua unit scripts.
To be able to use commands above, unzip your game into directory named "myGame.sdd", then you can directly change lua scripts (animations etc.) and reload.
Further reading
- Stumpy tutorial
- Polishing the stumpy
- Animation-LuaCallins
- Animation-LuaCallouts
- comparing Lua and COB unit scripts
- SpringTutorialGame contains simple examples unit scripts
- SpringRtsTutorialAnimDef examples animation scripts
TODO
- Conversion tool
- Performance measurements
- Link to article in piro's magazine
- Coordinate system (axis, direction of rotation, picture)