making Lua scripts for units

recreating units
Post Reply
User avatar
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France

making Lua scripts for units

Post by zuzuf » Sat Jul 04, 2009 7:09 pm

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).
=>;-D Penguin Powered

Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: making Lua scripts for units

Post by xpoy » Mon Jul 06, 2009 7:29 pm

Maybe we can post a topic in TAU for this new TA script

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest