--print("IslandMoving init") require "lua/entity.lua" require "lua/utilities.lua" myTime = 0 timer = myTime+10 move = 1 jumpPadDistance = 0 --myBase = spawn("Valve_BASE",position()) --myBase.scale(0.66,0.66,0.66) --myBase.moveRelative(ft2m(5),0,90) --myValve.moveRelative(ft2m(-5),0,90) --myValve.position(myBase.position()) myOriginalPosition = { position() } --myValvePosition = { myValve.position() } --myBasePosition = { myBase.position() } --myJumppadPosition = { myJumppad.position() } myWaypointPosition = { myWaypoint.position() } function calculatePositionOffset(p1,p2) local x = p2[1] - p1[1] local y = p2[2] - p1[2] local z = p2[3] - p1[3] return x,y,z end function applyPositionOffset(p1,p2) local x = p1[1] + p2[1] local y = p1[2] + p2[2] local z = p1[3] + p2[3] return x,y,z end myAttachments = { --{ object = myValve , offset = { calculatePositionOffset( myOriginalPosition , myValvePosition ) } }, --{ object = myBase , offset = { calculatePositionOffset( myOriginalPosition , myBasePosition ) } }, --{ object = myJumppad , offset = { calculatePositionOffset( myOriginalPosition , myJumppadPosition ) } }, } function updateAttachments() for k,v in pairs( myAttachments ) do v.object.position( applyPositionOffset( {position()} , v.offset ) ) end end function beStill() --print("beStill") if move == 1 then currentBehavior=moveAway end end function moveAway() --print("moveAway",myTime,timer) if myTime > timer and not movingAway then local x, y, z = unpack(myWaypointPosition) --print( x,y,z ) translateSmooth(x, y, z , 10,0,0) timer = myTime + 10 movingAway = true end if myTime >= timer then currentBehavior=moveBack movingAway = false end end function moveBack() --print("moveBack",myTime,timer) if move == 0 then currentBehavior = moveBackandStop timer = myTime + 10 end if myTime > timer and not movingBack then local x, y, z = unpack(myOriginalPosition) --print( x,y,z ) translateSmooth(x, y, z , 10,0,0) timer = myTime + 10 movingBack = true end if myTime >= timer then currentBehavior=moveAway movingBack = false end end function moveBackAndStop() --print("moveBackAndStop") local x, y, z = unpack(myOriginalPosition) translateSmooth(x, y, z,1,0,0) if myTime >= timer then currentBehavior=beStill end end currentBehavior = beStill function islandMovingTick() --currentBehavior() updateAttachments() end