diff --git a/data/levels/scripts/Template.lua b/data/levels/scripts/Template.lua index 97aef83..47effab 100644 --- a/data/levels/scripts/Template.lua +++ b/data/levels/scripts/Template.lua @@ -2,6 +2,10 @@ local global = require( "global" ) if(global.triggeredSCRIPTNAME == nil) then global.triggeredSCRIPTNAME = false end +if(global.triggeredSCRIPTNAMEUndo == nil) then + global.triggeredSCRIPTNAMEUndo = false +end + function trigger(objectToChange) if(global.triggeredSCRIPTNAME == false) then if(not level) then @@ -15,3 +19,17 @@ function trigger(objectToChange) print("SCRIPTNAME") end end + +function triggerUndo(objectToChange) + if(global.triggeredSCRIPTNAMEUndo == false) then + if(not level) then + print("No level found in Lua!") + return + end + + --enter the scripts undo code here + + global.triggeredSCRIPTNAMEUndo = true + print("SCRIPTNAMEUndo") + end +end diff --git a/data/levels/scripts/resetPlayer.lua b/data/levels/scripts/resetPlayer.lua index 30969c2..6262557 100644 --- a/data/levels/scripts/resetPlayer.lua +++ b/data/levels/scripts/resetPlayer.lua @@ -2,12 +2,14 @@ local global = require( "global" ) if(global.triggeredResetPlayer == nil) then global.triggeredResetPlayer = false end + function trigger(objectToChange) if(global.triggeredResetPlayer == false) then if(not level) then print("No level found in Lua!") return end + if(global.triggeredOpenFirstDoor == true) then if(global.openedSecondDoor == true) then if(global.triggeredOpenThirdDoor == true) then @@ -22,7 +24,6 @@ function trigger(objectToChange) level:resetPlayer() end - --global.triggeredResetPlayer = true print("reset player") end end diff --git a/data/levels/scripts/sunStart.lua b/data/levels/scripts/sunStart.lua new file mode 100644 index 0000000..c7865c0 --- /dev/null +++ b/data/levels/scripts/sunStart.lua @@ -0,0 +1,19 @@ +local global = require( "global" ) +if(global.triggeredSunStart == nil) then + global.triggeredSunStart = false +end + +function trigger(objectToChange) + if(global.triggeredSunStart == false) then + if(not level) then + print("No level found in Lua!") + return + end + + local time = os.clock() + global.sunStartTime = time + global.triggeredSunStart = true + + print("sunStart") + end +end diff --git a/data/levels/scripts/sunUpdate.lua b/data/levels/scripts/sunUpdate.lua new file mode 100644 index 0000000..49d25af --- /dev/null +++ b/data/levels/scripts/sunUpdate.lua @@ -0,0 +1,21 @@ +local global = require( "global" ) + +function trigger(objectToChange) + if(global.triggeredSunStart) then + if(not level) then + print("No level found in Lua!") + return + end + + local maxTimeDiff = 5 + local timeDiff = os.clock()- global.sunStartTime + if(timeDiff > maxTimeDiff)then + timeDiff = maxTimeDiff + end + timeDiff = timeDiff/maxTimeDiff + local x = 1 - 0.3 * timeDiff + local y = 0.7 * timeDiff + local z = timeDiff^0.5 * 0.6 -0.1 + level:setSunAngle(x,y,z) + end +end