From e66fb546b7598c3c1d30a1d2ab48e46a00545a36 Mon Sep 17 00:00:00 2001 From: Steffen Date: Sat, 17 Jan 2015 13:37:09 +0100 Subject: [PATCH] Updated scripts and added scripts for opening the door in Level1 --- Levels/scripts/Template.lua | 16 +++++++++++++++ Levels/scripts/deleteObject.lua | 4 ---- Levels/scripts/deleteRandomObject.lua | 4 ---- Levels/scripts/openDoor1 | 19 ------------------ Levels/scripts/openDoor1.lua | 28 +++++++++++++++++++++++++++ Levels/scripts/openDoor1undo.lua | 19 ++++++++++++++++++ Levels/scripts/openDoor2.lua | 28 +++++++++++++++++++++++++++ Levels/scripts/openDoor2undo.lua | 19 ++++++++++++++++++ Levels/scripts/openDoor3.lua | 28 +++++++++++++++++++++++++++ Levels/scripts/openDoor3undo.lua | 19 ++++++++++++++++++ 10 files changed, 157 insertions(+), 27 deletions(-) create mode 100644 Levels/scripts/Template.lua delete mode 100644 Levels/scripts/openDoor1 create mode 100644 Levels/scripts/openDoor1.lua create mode 100644 Levels/scripts/openDoor1undo.lua create mode 100644 Levels/scripts/openDoor2.lua create mode 100644 Levels/scripts/openDoor2undo.lua create mode 100644 Levels/scripts/openDoor3.lua create mode 100644 Levels/scripts/openDoor3undo.lua diff --git a/Levels/scripts/Template.lua b/Levels/scripts/Template.lua new file mode 100644 index 0000000..ef29605 --- /dev/null +++ b/Levels/scripts/Template.lua @@ -0,0 +1,16 @@ +if(triggeredSCRIPTNAME == nil) then + triggeredSCRIPTNAME = false +end +function trigger(objectToChange) + if(triggeredSCRIPTNAME == false) then + if(not level) then + print("No level found in Lua!") + return + end + + --enter the scripts code here and replace all occurences of SCRIPTNAME with the name of the script. + + triggeredSCRIPTNAME = true + print("SCRIPTNAME") + end +end diff --git a/Levels/scripts/deleteObject.lua b/Levels/scripts/deleteObject.lua index 6117ead..31fc432 100644 --- a/Levels/scripts/deleteObject.lua +++ b/Levels/scripts/deleteObject.lua @@ -7,10 +7,6 @@ function trigger(objectToChange) print("No level found in Lua!") return end - if(not physics) then - print("No physics found in Lua!") - return - end level:deleteObject(objectToChange) triggeredDeleteObject = true print("deleteObject") diff --git a/Levels/scripts/deleteRandomObject.lua b/Levels/scripts/deleteRandomObject.lua index 2f7db64..2fad2a1 100644 --- a/Levels/scripts/deleteRandomObject.lua +++ b/Levels/scripts/deleteRandomObject.lua @@ -7,10 +7,6 @@ function trigger(objectToChange) print("No level found in Lua!") return end - if(not physics) then - print("No physics found in Lua!") - return - end a = level:getObjectCount() rand = math.random(0, a - 1) level:deleteObject(rand) diff --git a/Levels/scripts/openDoor1 b/Levels/scripts/openDoor1 deleted file mode 100644 index 9969218..0000000 --- a/Levels/scripts/openDoor1 +++ /dev/null @@ -1,19 +0,0 @@ -function trigger(objectToChange) - if(not level) then - print("No level found in Lua!") - return - end - if(not physics) then - print("No physics found in Lua!") - return - end - - if(not openDoorCounter) then - openDoorCounter = 0 - end - openDoorCounter = openDoorCounter + 1 - - if (openDoorCounter == 3) then - - end -end diff --git a/Levels/scripts/openDoor1.lua b/Levels/scripts/openDoor1.lua new file mode 100644 index 0000000..cf53872 --- /dev/null +++ b/Levels/scripts/openDoor1.lua @@ -0,0 +1,28 @@ +if(triggeredOpenDoor1 == nil) then + triggeredOpenDoor1 = false +end +function trigger(objectToChange) + if(triggeredOpenDoor1 == false) then + if(not level) then + print("No level found in Lua!") + return + end + + if(not openDoorCounter) then + openDoorCounter = 0 + end + openDoorCounter = openDoorCounter + 1 + if (openDoorCounter == 3) then + local strength = 1 + local xPos = 0 + local yPos = 0 + local zPos = 0 + level:moveObject(objectToChange, strength, xPos, yPos, zPos) + print("Opening the door") + end + triggeredOpenDoor1undo = false + + triggeredOpenDoor1 = true + print("openDoor1") + end +end diff --git a/Levels/scripts/openDoor1undo.lua b/Levels/scripts/openDoor1undo.lua new file mode 100644 index 0000000..a475744 --- /dev/null +++ b/Levels/scripts/openDoor1undo.lua @@ -0,0 +1,19 @@ +if(triggeredOpenDoor1undo == nil) then + triggeredOpenDoor1undo = false +end +function trigger(objectToChange) + if(triggeredOpenDoor1undo == false) then + if(not level) then + print("No level found in Lua!") + return + end + + if(triggeredOpenDoor1) then + openDoorCounter = openDoorCounter - 1 + triggeredOpenDoor1 = false + end + + triggeredOpenDoor1undo = true + print("openDoor1undo") + end +end diff --git a/Levels/scripts/openDoor2.lua b/Levels/scripts/openDoor2.lua new file mode 100644 index 0000000..debaa25 --- /dev/null +++ b/Levels/scripts/openDoor2.lua @@ -0,0 +1,28 @@ +if(triggeredOpenDoor2 == nil) then + triggeredOpenDoor2 = false +end +function trigger(objectToChange) + if(triggeredOpenDoor2 == false) then + if(not level) then + print("No level found in Lua!") + return + end + + if(not openDoorCounter) then + openDoorCounter = 0 + end + openDoorCounter = openDoorCounter + 1 + if (openDoorCounter == 3) then + local strength = 1 + local xPos = 0 + local yPos = 0 + local zPos = 0 + level:moveObject(objectToChange, strength, xPos, yPos, zPos) + print("Opening the door") + end + triggeredOpenDoor2undo = false + + triggeredOpenDoor2 = true + print("openDoor2") + end +end diff --git a/Levels/scripts/openDoor2undo.lua b/Levels/scripts/openDoor2undo.lua new file mode 100644 index 0000000..eb7e20d --- /dev/null +++ b/Levels/scripts/openDoor2undo.lua @@ -0,0 +1,19 @@ +if(triggeredOpenDoor2undo == nil) then + triggeredOpenDoor2undo = false +end +function trigger(objectToChange) + if(triggeredOpenDoor2undo == false) then + if(not level) then + print("No level found in Lua!") + return + end + + if(triggeredOpenDoor2) then + openDoorCounter = openDoorCounter - 1 + triggeredOpenDoor2 = false + end + + triggeredOpenDoor2undo = true + print("openDoor2undo") + end +end diff --git a/Levels/scripts/openDoor3.lua b/Levels/scripts/openDoor3.lua new file mode 100644 index 0000000..94f5544 --- /dev/null +++ b/Levels/scripts/openDoor3.lua @@ -0,0 +1,28 @@ +if(triggeredOpenDoor3 == nil) then + triggeredOpenDoor3 = false +end +function trigger(objectToChange) + if(triggeredOpenDoor3 == false) then + if(not level) then + print("No level found in Lua!") + return + end + + if(not openDoorCounter) then + openDoorCounter = 0 + end + openDoorCounter = openDoorCounter + 1 + if (openDoorCounter == 3) then + local strength = 1 + local xPos = 0 + local yPos = 0 + local zPos = 0 + level:moveObject(objectToChange, strength, xPos, yPos, zPos) + print("Opening the door") + end + triggeredOpenDoor3undo = false + + triggeredOpenDoor3 = true + print("openDoor3") + end +end diff --git a/Levels/scripts/openDoor3undo.lua b/Levels/scripts/openDoor3undo.lua new file mode 100644 index 0000000..ce66ff7 --- /dev/null +++ b/Levels/scripts/openDoor3undo.lua @@ -0,0 +1,19 @@ +if(triggeredOpenDoor3undo == nil) then + triggeredOpenDoor3undo = false +end +function trigger(objectToChange) + if(triggeredOpenDoor3undo == false) then + if(not level) then + print("No level found in Lua!") + return + end + + if(triggeredOpenDoor3) then + openDoorCounter = openDoorCounter - 1 + triggeredOpenDoor3 = false + end + + triggeredOpenDoor3undo = true + print("openDoor3undo") + end +end