I am trying to write a script that replaces a unit once destroyed with a visually identical unit controlled by another player. I would just use capture, but there are other scripts that are too difficult to stay consistent within the same unit script. (Building, etc.)
That being said, is there any way to pass a piece spin speed to the gadget I've written to do the swap?
Or, alternatively, to change what a factory builds depending on who controls it?
Any way to get piece rotation outside unit script?
Moderator: Moderators
Re: Any way to get piece rotation outside unit script?
This sounds easier, if you mean e.g. 'Federation can build x,y,z from this factory' but 'Borg can build a,b,c'zalpha wrote:Or, alternatively, to change what a factory builds depending on who controls it?
Re: Any way to get piece rotation outside unit script?
How can I do this?FLOZi wrote:This sounds easier, if you mean e.g. 'Federation can build x,y,z from this factory' but 'Borg can build a,b,c'zalpha wrote:Or, alternatively, to change what a factory builds depending on who controls it?
Re: Any way to get piece rotation outside unit script?
You can get the side name from teamID via GetTeamInfo e.g.
You could use the gadget:UnitTaken callin to detect when the factory is captured, and by what teamID.
You'd then need to use these functions:
http://springrts.com/wiki/Lua_SyncedCtr ... scriptions
To recreate the build menu.
(There's a similar thing in this gadget, though infact it can build all units by definition, but certain units are hidden until you hold a 'prerequisite' building. This is probably easier than adding/removing. )
Code: Select all
local sideName = select(5, Spring.GetTeamInfo(teamID))
You'd then need to use these functions:
http://springrts.com/wiki/Lua_SyncedCtr ... scriptions
To recreate the build menu.
(There's a similar thing in this gadget, though infact it can build all units by definition, but certain units are hidden until you hold a 'prerequisite' building. This is probably easier than adding/removing. )
Re: Any way to get piece rotation outside unit script?
yes:Any way to get piece rotation outside unit script?
Code: Select all
local rx,ry,rz = Spring.UnitScript.CallAsUnit(unitID, Spring.UnitScript.GetPieceRotation, pid)
local px,py,pz = Spring.UnitScript.CallAsUnit(unitID, Spring.UnitScript.GetPieceTranslation, pid)
http://springrts.com/phpbb/viewtopic.ph ... 4&p=468594
http://springrts.com/wiki/Animation-Lua ... #AnimationThat being said, is there any way to pass a piece spin speed to the gadget I've written to do the swap?
Spring.UnitScript.IsInSpin (number piece, number axis) -> boolean

You mean when dead the unit is supposed to change to the team that killed it? If you can explain a bit more what excactly you want there might be other ways to do it.I am trying to write a script that replaces a unit once destroyed with a visually identical unit controlled by another player.