-
Notifications
You must be signed in to change notification settings - Fork 199
/
pieceControl.lua
36 lines (32 loc) · 992 Bytes
/
pieceControl.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local IsInTurn = Spring.UnitScript.IsInTurn
local IsInMove = Spring.UnitScript.IsInMove
local GetPieceRotation = Spring.UnitScript.GetPieceRotation
local GetPieceTranslation = Spring.UnitScript.GetPieceTranslation
local SpringGetUnitRulesParam = Spring.GetUnitRulesParam
local SpringGetUnitIsStunned = Spring.GetUnitIsStunned
-- for some reason a 4th argument is required
local ROTATION_STOP = math.rad(3)
local TRANSLATION_STOP = 1
function StopTurn(piece, axis)
if IsInTurn(piece, axis) then
local rot = select(axis, GetPieceRotation(piece))
Turn(piece, axis, rot, ROTATION_STOP)
return true
end
return false
end
function StopMove(piece, axis)
if IsInMove(piece, axis) then
local trans = select(axis, GetPieceRotation(piece))
Move(piece, axis, trans, TRANSLATION_STOP)
return true
end
return false
end
function IsDisarmed ()
if ((SpringGetUnitRulesParam (unitID, "disarmed") == 1) or SpringGetUnitIsStunned (unitID)) then
return true
else
return false
end
end