function init() motors = FindJoints("motor") hingemotors = FindJoints("hingemotor") dir = 0 speed = 0.65 accelerationTime = 2 startbutton = FindShape("startbutton") armbutton = FindShape("armbutton") stopbutton = FindShape("stopbutton") SetTag(startbutton, "interact", "loc@START") SetTag(armbutton, "interact", "loc@START_ARMS") SetTag(stopbutton, "interact", "loc@EMERGENCY_STOP") buttonClick = LoadSound("clickup.ogg") motorSound = LoadLoop("vehicle/hydraulic-loop.ogg") body = FindBody("body") end function tick(dt) if GetPlayerInteractShape() == startbutton then if InputPressed("interact") then SetValue("dir", 1, "linear", accelerationTime) PlaySound(buttonClick,GetShapeWorldTransform(startbutton).pos) end end if GetPlayerInteractShape() == armbutton then if InputPressed("interact") then for i=1,#hingemotors do SetTag(hingemotors[i],"hingemotor","1") end PlaySound(buttonClick,GetShapeWorldTransform(armbutton).pos) end end if GetPlayerInteractShape() == stopbutton then if InputPressed("interact") then dir = 0 for i=1,#hingemotors do SetTag(hingemotors[i],"hingemotor","0") end PlaySound(buttonClick,GetShapeWorldTransform(stopbutton).pos) end end if dir ~= 0 then PlayLoop(motorSound,GetBodyTransform(body).pos) end for i=1,#motors do local tagValue = 1 if GetTagValue(motors[i], "motor") ~= "" then tagValue = GetTagValue(motors[i],"motor") end SetJointMotor(motors[i], dir*speed*tagValue) end end