require "lua/entity.lua" require "lua/utilities.lua" myTime = 0 treasureMapPointDistance = ft2m(10) function treasureMapSTARTUP() --print("executing treasureMapSTARTUP") wayPoints = treasureMapPoints myLineActors = {} timer = 0 startPos_Actor = nil --myself.placement.activationrange = 0 --myself.placement.deactivationbuffer = 0 endPos_Actor = nil myWaypoints = {} startPos_Waypoint = wayPoints[1] endPos_Waypoint = wayPoints[ #wayPoints ] --set [set] myWaypoints include !!! Couldn't parse RHS this.ScriptGroupStack unknown type: ScriptGroupStack --set [set] myWaypoints exclude !!! Couldn't parse RHS this.ScriptGroupStack2c unknown type: ScriptGroupStack debug_ScratchDistance = 0 scratchID = 0 scratchWaypointRef = nil currentWaypointRef = nil nextWaypointRef = nil scratchHeading_Previous = 0 scratchHeading_Next = 0 heading = 0 scratchTilt_Next = 0 tilt = 0 scratchTilt_Previous = 0 fadeID = 1 fadeSet = nil actor_FadeOut = nil actor_FadeIn = nil --default, may be overridden in treasureMapInitialize() fadeWaveLength = 6 currentBehavior=treasureMapInitialize end --print("defining treasureMapInitialize") function treasureMapInitialize() --print("executing treasureMapInitialize") local verticalOffset = ft2m(0.5) --originally 0.5 --try to snap waypoints to ground for k,v in pairs(wayPoints) do local lx,ly,lz = landingPos( v.position() ) if lx then v.position(lx,ly,lz) end end mapStart = spawn( mapStartPieceName, startPos_Waypoint.position() ) mapStart.moveRelative( verticalOffset , 0 , 90 ) --mapStart.placement.deactivationbuffer = 0 mapStart.scale(1.50,1.50,1.50) --mapStart.setAlpha(0) mapStart.setAlphaSmooth(0,1,1) mapStart.setColor(0,0.15,1) mapEnd = spawn( mapEndPieceName , endPos_Waypoint.position() ) mapEnd.moveRelative( verticalOffset , 0 , 90 ) --mapEnd.placement.deactivationbuffer = 0 mapEnd.scale(1.50,1.50,1.50) --mapEnd.setAlpha(0) mapEnd.setAlphaSmooth(0,1,1) mapEnd.setColor(1,0.2,0.2) print(#wayPoints,"waypoints - spawning line segments") for k,v in pairs(wayPoints) do if (k ~= 1 and k ~= #wayPoints) then --scratchWaypointRef = myself.actor.waypoints [myWaypoints .count] nextWaypointRef = wayPoints[k+1] lastWaypointRef = wayPoints [k-1] --print("spawning line piece ",k,"at",v,v.position() ) newLinePiece = spawn(mapLinePieceName,v.position()) --print("spawned line piece ",k,"at",v,v.position() ) myLineActors[k-1] = newLinePiece --newLinePiece.placement.ID = wayPoints .count newLinePiece.lookat(nextWaypointRef.position()) --print ( newLinePiece.rotation() ) if lastWaypointRef then local rx1,ry1,rz1 = newLinePiece.rotation() newLinePiece.lookat(lastWaypointRef.position()) --print ( newLinePiece.rotation() ) local rx2,ry2,rz2 = newLinePiece.rotation() rz2 = rz2 + 180 local frx,fry,frz = (rx1 + rx2) / 2 , (ry1 + ry2) / 2 , (rz1 + rz2) / 2 newLinePiece.rotation( frx,fry,frz ) end --print ( newLinePiece.rotation() ) --newLinePiece.orientation.facing = nextWaypointRef .position.heading --newLinePiece.orientation.tilt = nextWaypointRef .position.pitch newLinePiece.moveRelative(verticalOffset ,0,90) --newLinePiece.placement.deactivationbuffer = 0 newLinePiece.setColor(1.25,1.25,1) newLinePiece.scale(0.01,0.01,0.01) --slideValue(newLinePiece.scale.x,2.00,0.5,0,25) --slideValue(newLinePiece.scale.y,2.00,0.5,0,25) --slideValue(newLinePiece.scale.z,2.00,0.5,0,25) newLinePiece.scaleSmooth(2,2,2,0.5) --newLinePiece.scale(2,2,2) else --print("skipping first or last waypoint",k,v) end end --flow loop --[[ XPEC MD - setFacingValues seems to be some polish for the rotation of the line segments ]] --currentBehavior=setFacingValues if #myLineActors <= 6 then fadeWaveLength = #myLineActors - 1 --fadeWaveLength = math.floor( #myLineActors / 2 ) end currentBehavior=treasureMapPulse end --OpFlowBehavior --print("defined treasureMapInitialize") --print("defining treasureMapPulse") function treasureMapPulse() --print("executing treasureMapPulse") if myTime >= timer then timer = myTime + 0.2 --timer = myTime + 0.125 --timer = myTime + 0.8 actor_FadeOut = myLineActors[fadeID] fadeInIndex = fadeID + fadeWaveLength if fadeInIndex > #myLineActors then fadeInIndex = fadeInIndex - #myLineActors end actor_FadeIn = myLineActors[fadeInIndex] --print(fadeID,fadeInIndex) --slideValue(actor_FadeIn .placement.scale.x,300,0.5,25,25) --slideValue(actor_FadeIn .placement.scale.y,300,0.5,25,25) --slideValue(actor_FadeIn .placement.scale.z,300,0.5,25,25) if actor_FadeIn ~= nil then --actor_FadeIn.scale(3,3,3) local rx,ry,rz = actor_FadeIn.rotation() actor_FadeIn.scaleSmooth(3,3,3,0.4) actor_FadeIn.setAlphaSmooth(0.5,0.99,0.4) --actor_FadeIn.rotateSmooth( _ , _ , _ ,0.5,0.5,0.5) end --slideValue(actor_FadeOut .placement.scale.x,200,0.5,25,25) --slideValue(actor_FadeOut .placement.scale.y,200,0.5,25,25) --slideValue(actor_FadeOut .placement.scale.z,200,0.5,25,25) --print("setting Fade Out scale") --actor_FadeOut.scale(2,2,2) local rx,ry,rz = actor_FadeOut.rotation() actor_FadeOut.scaleSmooth(2,2,2,0.4) actor_FadeOut.setAlphaSmooth(0.99,0.5,0.4) --actor_FadeOut.rotateSmooth( rx , ry , rz ,0.5,0.5,0.5) fadeID = fadeID + 1 --inc value if fadeID > #myLineActors then fadeID = 1 end end end --print("defined Done") currentBehavior = treasureMapSTARTUP function treasureMapDeletePath() mapStart.delete() mapEnd.delete() for k,v in pairs(myLineActors) do v.delete() end currentBehavior=treasureMapInitialize end function treasureMapPathTick() --print("TreasureMapPath tick") myTime = myTime + dt --print(myTime,timer) currentBehavior() end --[[ while tick() do treasureMapPathTick() end ]] --function SHUTDOWN() --remove myLineActors --remove endPos_Actor --remove startPos_Actor --end --continue