print("raft init") require "lua/entity.lua" require "lua/utilities.lua" myTime = 0 waypoints = { object("Raft_Controller_01_waypoint_0"), object("Raft_Controller_01_waypoint_1"), } position( waypoints[2].position() ) rotation( waypoints[2].rotation() ) nextMoveTime = 20 moveLength = 9 moveDelay = 3 currentWaypoint = 2 stopTime = math.huge while tick() do myTime = myTime + dt if nextMoveTime <= myTime and not hidden then currentWaypoint = currentWaypoint + 1 if currentWaypoint > #waypoints then currentWaypoint = 1 end --print( "raft moving to " .. currentWaypoint ) trigger.send(1,"playSoundMoving") x,y,z = waypoints[currentWaypoint].position() translateSmooth( x , y , z , moveLength , 0 , 0 ) rx,ry,rx = waypoints[currentWaypoint].rotation() rotateSmooth( rx , ry , rz , moveLength , 0 , 0 ) nextMoveTime = myTime + moveLength + moveDelay stopTime = myTime + moveLength end if stopTime <= myTime then trigger.send(1,"playSoundStop") stopTime = math.huge end if trigger.received(1,"hide") then print("raft hide") setAlpha(0) hidden = true end if trigger.received(1,"show") then print("raft show") position( waypoints[1].position() ) rotation( waypoints[1].rotation() ) currentWaypoint = 1 nextMoveTime = myTime + moveLength + moveDelay setAlpha(1) hidden = false end end