Page 1 of 1

Lua animation equivalent of Spring.CallCOBScript?

Posted: 15 Mar 2010, 23:53
by PTSnoop
A quick newb question. I'm using Lua unit animation scripts instead of COB/BOS; how do I call unit animation scripts in other gadgets?

Also: is there a way of calling animation script things (Hide, Turn etc) in other gadgets?

Re: Lua animation equivalent of Spring.CallCOBScript?

Posted: 16 Mar 2010, 10:29
by zwzsg
Have you seen this page? http://springrts.com/wiki/Mod_and_Unit_ ... uote][list][*]Animation-LuaScripting[*][/list][/quote]


You can call Lua's UnitScript commands, such as hide/show, from a plain regular gadget, with Spring.UnitScript.CallAsUnit.

For instance, to force the transport to drop a commander in my JailBreak gadget, I do:

Code: Select all

Spring.UnitScript.CallAsUnit(transID,Spring.UnitScript.DropUnit,comID)
I am however pretty sure that this is not the way you're supposed to write unit animations. Again, read the wiki for info.

Re: Lua animation equivalent of Spring.CallCOBScript?

Posted: 20 Mar 2010, 01:03
by PTSnoop
All seems to be working; thanks for the wiki links.

One thing I can't find on the wiki, though. Suppose I want to give a unit another button for some command (morph, or whatever), how would I do that? (I've tried copying from The Cursed's burrow gadget but I get error messages.)

Re: Lua animation equivalent of Spring.CallCOBScript?

Posted: 20 Mar 2010, 01:08
by jK
There is a GG table which is shared between all gadgets use it to make functions available to other gadgets.

e.g.

Code: Select all

GG.unitscripts = GG.unitscripts or {}
GG.unitscripts.MyFunc = MyFunc2

Re: Lua animation equivalent of Spring.CallCOBScript?

Posted: 20 Mar 2010, 11:41
by Tobi
Also there's Spring.UnitScript.GetScriptEnv(unitID) exported by the unit_script.lua gadget. This gives direct access to the globals table of the script of a unit.