Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local body = piece "body"
- local main = piece "main"
- local head = piece "head"
- local pipesL = piece "pipesL"
- local pipesR = piece "pipesR"
- local pistons = piece "pistons"
- local arms = piece "arms"
- local platform = piece "platform"
- local turret = piece "turret"
- local guns = piece "guns"
- local flair1 = piece "flair1"
- local flair2 = piece "flair2"
- local back = piece "back"
- local rocket1 = piece "rocket1"
- local rocket2 = piece "rocket2"
- local rocket3 = piece "rocket3"
- local rocket4 = piece "rocket4"
- local armBR = piece "armBR"
- local wheelBR = piece "wheelBR"
- local trackBR1 = piece "trackBR1"
- local trackBR2 = piece "trackBR2"
- local BR = piece "BR"
- local armFR = piece "armFR"
- local wheelFR = piece "wheelFR"
- local trackFR1 = piece "trackFR1"
- local trackFR2 = piece "trackFR2"
- local FR = piece "FR"
- local armBL = piece "armBL"
- local wheelBL = piece "wheelBL"
- local trackBL1 = piece "trackBL1"
- local trackBL2 = piece "trackBL2"
- local BL = piece "BL"
- local armFL = piece "armFL"
- local wheelFL = piece "wheelFL"
- local trackFL1 = piece "trackFL1"
- local trackFL2 = piece "trackFL2"
- local FL = piece "FL"
- local SIG_MOVE = 1 --signal for the move animation thread
- local SIG_SUSP = 2 --signal for the suspension animation thread
- local BRA = 0
- local FRA = 0
- local BLA = 0
- local FLA = 0
- local bodyA = 0
- local function susp()
- Signal(SIG_SUSP)
- SetSignalMask(SIG_SUSP)
- while (true) do
- --if ground_height_old == null then
- --ground_height_old = 0
- --end
- unitposx,unitposy,unitposz = Spring.GetUnitPosition(unitID)
- ground_height = Spring.GetGroundHeight(unitposx,unitposz)
- BRx,BRy,BRz = Spring.GetUnitPiecePosDir(unitID,BR)
- BR_height = ground_height-(Spring.GetGroundHeight(BRx,BRz))
- FRx,FRy,FRz = Spring.GetUnitPiecePosDir(unitID,FR)
- FR_height = ground_height-(Spring.GetGroundHeight(FRx,FRz))
- BLx,BLy,BLz = Spring.GetUnitPiecePosDir(unitID,BL)
- BL_height = ground_height-(Spring.GetGroundHeight(BLx,BLz))
- FLx,FLy,FLz = Spring.GetUnitPiecePosDir(unitID,FL)
- FL_height = ground_height-(Spring.GetGroundHeight(FLx,FLz))
- --Spring.Echo (BR_height)
- --Spring.Echo (FR_height)
- --Spring.Echo (BL_height)
- --Spring.Echo (FL_height)
- bodyLRHeight = ((BR_height+FR_height)/4)-((BL_height+FL_height)/4)
- Spring.Echo (bodyLRHeight)
- bodyTilt = math.asin(bodyLRHeight/25)
- Spring.Echo (bodyTilt)
- BRA = math.asin((BR_height-bodyLRHeight)/47)
- FRA = math.asin((FR_height-bodyLRHeight)/47)
- BLA = math.asin((BL_height+bodyLRHeight)/47)
- FLA = math.asin((FL_height+bodyLRHeight)/47)
- bodyA = (FRA+FLA)/2
- Turn (main, 3, bodyTilt, math.rad(20))
- Turn (platform, 3, -bodyTilt, math.rad(20))
- Move (armBR, 2, -bodyLRHeight, 10)
- Move (armFR, 2, -bodyLRHeight, 10)
- Move (armBL, 2, bodyLRHeight, 10)
- Move (armFL, 2, bodyLRHeight, 10)
- --height_dif = math.sqrt(math.abs(ground_height - ground_height_old) * 10)
- --Spring.Echo (height_dif)
- --Move (main, 2, -height_dif, 5)
- Turn (armBR, 1, -BRA, math.rad(20))
- Turn (armFR, 1, FRA, math.rad(20))
- Turn (armBL, 1, -BLA, math.rad(20))
- Turn (armFL, 1, FLA, math.rad(20))
- Turn (main, 1, bodyA, math.rad(20))
- Turn (platform, 1, -bodyA)
- Move (platform, 2, -bodyA*10)
- --ground_height_old = ground_height
- Sleep(40)
- --Sleep(200)
- end
- end
- function script.Create()
- Show(trackFL1)
- Show(trackFR1)
- Show(trackBL1)
- Show(trackBR1)
- Hide(trackFL2)
- Hide(trackFR2)
- Hide(trackBL2)
- Hide(trackBR2)
- Turn (armBR, 1, 0)
- Turn (armFR, 1, 0)
- Turn (armBL, 1, 0)
- Turn (armFL, 1, 0)
- end
- local function move()
- Signal(SIG_MOVE)
- SetSignalMask(SIG_MOVE)
- while (true) do
- Show(trackFL1)
- Show(trackFR1)
- Show(trackBL1)
- Show(trackBR1)
- Hide(trackFL2)
- Hide(trackFR2)
- Hide(trackBL2)
- Hide(trackBR2)
- Sleep(70)
- Show(trackFL2)
- Show(trackFR2)
- Show(trackBL2)
- Show(trackBR2)
- Hide(trackFL1)
- Hide(trackFR1)
- Hide(trackBL1)
- Hide(trackBR1)
- Sleep(70)
- end
- end
- function script.Killed()
- end
- local function open()
- StartThread (move)
- Turn (head, 1, -(math.rad(30)+bodyA), math.rad(40))
- Turn (pipesL, 1, (math.rad(30)+bodyA), math.rad(40))
- Turn (pipesR, 1, (math.rad(30)+bodyA), math.rad(40))
- Turn (platform, 1, -(math.rad(30)+bodyA), math.rad(40))
- Move (platform, 3, 7, 10)
- Move (platform, 2, 2, 4)
- Turn (main, 1, (math.rad(30)+bodyA), math.rad(40))
- Turn (back, 1, -math.rad(50), math.rad(50))
- Turn (pistons, 1, -math.rad(15), math.rad(15))
- Move (arms, 3, -5, 5)
- Move (arms, 2, 5, 5)
- Move (body, 2, 12, 12)
- Turn (armBR, 1, -(math.rad(20)+BRA), math.rad(20))
- Turn (armFR, 1, (math.rad(20)+FRA), math.rad(20))
- Turn (armBL, 1, -(math.rad(20)+BLA), math.rad(20))
- Turn (armFL, 1, (math.rad(20)+FLA), math.rad(20))
- Sleep(1000)
- Signal(SIG_MOVE)
- end
- local function close()
- StartThread (move)
- Turn (head, 1, 0, math.rad(40))
- Turn (pipesL, 1, 0, math.rad(40))
- Turn (pipesR, 1, 0, math.rad(40))
- Turn (platform, 1, 0, math.rad(40))
- Move (platform, 3, 0, 10)
- Move (platform, 2, 0, 1)
- Turn (main, 1, bodyA, math.rad(30))
- Turn (back, 1, 0, math.rad(50))
- Turn (pistons, 1, 0, math.rad(15))
- Move (arms, 3, 0, 5)
- Move (arms, 2, 0, 5)
- Move (body, 2, 0, 12)
- Turn (armBR, 1, -BRA, math.rad(20))
- Turn (armFR, 1, FRA, math.rad(20))
- Turn (armBL, 1, -BLA, math.rad(20))
- Turn (armFL, 1, FLA, math.rad(20))
- Sleep(1000)
- Signal(SIG_MOVE)
- end
- function script.Activate()
- StartThread (open)
- return 1
- end
- function script.Deactivate()
- StartThread (close)
- return 0
- end
- function script.StartMoving()
- StartThread (move)
- StartThread (susp)
- end
- function script.StopMoving()
- Signal(SIG_MOVE)
- Signal(SIG_SUSP)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement