Quick question: TeamID in animation scripts

Quick question: TeamID in animation scripts

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

Quick question: TeamID in animation scripts

Post by PTSnoop »

I'm trying to write a Lua unit animation script such that a building is destroyed if the player who owns it runs out of energy. So far I've got

Code: Select all

local function expire()
--	teamID = ???
	while true do
		if Spring.GetTeamResources(teamID, "energy") < 10 then
			Spring.DestroyUnit(unitID)
		end
		Sleep(1750)
	end
end
How do I get the teamID of the unit running the script?

Also: is there a separate GetPlayerResources? I couldn't find one on the wiki. Or will GetTeamResources work fine here, even if the player's allied to someone with plenty of energy?
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Quick question: TeamID in animation scripts

Post by CarRepairer »

http://springrts.com/wiki/Lua_SyncedRead

Spring.GetUnitTeam
( number unitID ) -> nil | number teamID
User avatar
PTSnoop
Posts: 97
Joined: 09 Sep 2009, 19:05

Re: Quick question: TeamID in animation scripts

Post by PTSnoop »

It's working now. Thanks!
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6243
Joined: 29 Apr 2005, 01:14

Re: Quick question: TeamID in animation scripts

Post by FLOZi »

Generally speaking wrt the lua API, 'team' means 'player team' and 'ally team' means the team of allied player teams.
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: Quick question: TeamID in animation scripts

Post by Tribulex »

doesnt this make more sense as a gadget? i think it would be more efficient. then again its not that big of a deal.
Post Reply

Return to “Lua Scripts”