Page 1 of 1

Any way to get piece rotation outside unit script?

Posted: 25 Apr 2013, 18:54
by zalpha
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?

Re: Any way to get piece rotation outside unit script?

Posted: 25 Apr 2013, 19:14
by FLOZi
zalpha wrote:Or, alternatively, to change what a factory builds depending on who controls it?
This sounds easier, if you mean e.g. 'Federation can build x,y,z from this factory' but 'Borg can build a,b,c'

Re: Any way to get piece rotation outside unit script?

Posted: 25 Apr 2013, 19:22
by zalpha
FLOZi wrote:
zalpha wrote:Or, alternatively, to change what a factory builds depending on who controls it?
This sounds easier, if you mean e.g. 'Federation can build x,y,z from this factory' but 'Borg can build a,b,c'
How can I do this?

Re: Any way to get piece rotation outside unit script?

Posted: 25 Apr 2013, 19:31
by FLOZi
You can get the side name from teamID via GetTeamInfo e.g.

Code: Select all

local sideName = select(5, Spring.GetTeamInfo(teamID))
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. )

Re: Any way to get piece rotation outside unit script?

Posted: 26 Apr 2013, 10:26
by knorke
Any way to get piece rotation outside unit script?
yes:

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)
as used in
http://springrts.com/phpbb/viewtopic.ph ... 4&p=468594
That being said, is there any way to pass a piece spin speed to the gadget I've written to do the swap?
http://springrts.com/wiki/Animation-Lua ... #Animation
Spring.UnitScript.IsInSpin (number piece, number axis) -> boolean
:arrow: seems you can only read *if* something is spinning but not how fast.
I am trying to write a script that replaces a unit once destroyed with a visually identical unit controlled by another player.
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.