Any way to get piece rotation outside unit script?

Any way to get piece rotation outside unit script?

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
zalpha
Posts: 23
Joined: 19 Mar 2013, 18:39

Any way to get piece rotation outside unit script?

Post 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?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

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

Post 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'
zalpha
Posts: 23
Joined: 19 Mar 2013, 18:39

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

Post 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?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

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

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

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

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

Return to “Game Development”