lua animation script questions.

lua animation script questions.

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

Moderator: Moderators

Post Reply
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

lua animation script questions.

Post 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" ?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: lua animation script questions.

Post by knorke »

User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: lua animation script questions.

Post 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
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: lua animation script questions.

Post 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?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: lua animation script questions.

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

Return to “Lua Scripts”