Lua animation equivalent of Spring.CallCOBScript?

Lua animation equivalent of Spring.CallCOBScript?

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
PTSnoop
Posts: 97
Joined: 09 Sep 2009, 19:05

Lua animation equivalent of Spring.CallCOBScript?

Post 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?
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Lua animation equivalent of Spring.CallCOBScript?

Post 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.
User avatar
PTSnoop
Posts: 97
Joined: 09 Sep 2009, 19:05

Re: Lua animation equivalent of Spring.CallCOBScript?

Post 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.)
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Lua animation equivalent of Spring.CallCOBScript?

Post 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
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Lua animation equivalent of Spring.CallCOBScript?

Post 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.
Post Reply

Return to “Lua Scripts”