Page 1 of 1

making Lua scripts for units

Posted: Sat Jul 04, 2009 7:09 pm
by zuzuf
Now that we have a working Lua scripting engine for units without problems like memory usage or poor performance, we can create Lua scripts in order to replace BOS/COB copyrighted files.
All the Lua files in scripts/ should already show how those scripts are designed. You just create an object that will contain all the functions the unit will be able to use (NB: function names are case sensitive!!). You just need to code the same functions as in TA, except you may want to add a Save and a Restore function that will store the unit state more precisely and will save/restore the unit state when you save and reload a game (this is needed only for a few units that don't support to have their scripts reset, note that Create is called before Restore when the game is reloaded).

For anything else regarding available functions, refer to lua_prototypes.txt and scripts/ta3d.lh (which maps those functions on the unit object). Remember Lua scripts (for units only) work on a unit object (the "this" table you see everywhere in the scripts I wrote) that identifies the unit, you need it to animate objects on that unit (you could also animate another one, but you need its unit object, which can be found in the __units table).

Re: making Lua scripts for units

Posted: Mon Jul 06, 2009 7:29 pm
by xpoy
:roll:
Maybe we can post a topic in TAU for this new TA script