Page 1 of 1
lua animation script questions.
Posted: 27 Nov 2012, 04:04
by smoth
How do retrieve the current unit's unitid to look up details about it?
how can I do a check to see if a piece exists before specifying piece = "piecename" ?
Re: lua animation script questions.
Posted: 27 Nov 2012, 09:08
by knorke
Re: lua animation script questions.
Posted: 27 Nov 2012, 15:15
by smoth
Thanks!
I am running into a new problem
Code: Select all
if lus then
-- what goes here for lua animation scripts?
-- spCallAsUnit(unitID, env["LaunchSmoke"])
-- and
-- spCallAsUnit(unitID, "LaunchSmoke")
-- doesn't pick up the launch smoke function
-- instead both result in
-- Incorrect arguments to CallAsUnit()
return true
else
spCallCobScript(unitID, "LaunchSmoke",0)
return true
end
Re: lua animation script questions.
Posted: 27 Nov 2012, 15:58
by knorke
Re: lua animation script questions.
Posted: 27 Nov 2012, 17:17
by smoth
:\
Code: Select all
Spring.Echo("test ")
Spring.Echo(unitID)
Spring.Echo(UnitDefs[unitID])
[f=0000166] test
[f=0000166] 27633
[f=0000166] nil
why would it be nil?
Re: lua animation script questions.
Posted: 27 Nov 2012, 18:33
by knorke
the entries in UnitDefs are indexed by unitDefIDs but you put in a unitID.
and echo can not print a table, you need to loop through it.
the GRTS_Ability_smokelauncher.lua is actually good example for that as it uses all this. if you are trying to make it work with cob and lua try like this:
Code: Select all
env = Spring.UnitScript.GetScriptEnv(u)
if (env) then Spring.UnitScript.CallAsUnit(u, env.LaunchSmoke, 0)
else--its a cob script?
Spring.CallCOBScript(u, "LaunchSmoke",0)
end
(never tested if the else works like this to detect between lus/cob, if not remove the cob part)