From 857fc76c40a814bd05d63b3f32bdc0d4804250cd Mon Sep 17 00:00:00 2001 From: Faerbit Date: Sun, 15 Mar 2015 18:46:44 +0100 Subject: [PATCH] Removing debug output from lua scripts for release builds. --- data/levels/scripts/Template.lua | 12 ++++++++---- data/levels/scripts/firstCheckpoint.lua | 6 ++++-- data/levels/scripts/openFirstDoor.lua | 12 ++++++++---- data/levels/scripts/openSecondDoor1.lua | 12 ++++++++---- data/levels/scripts/openSecondDoor2.lua | 12 ++++++++---- data/levels/scripts/openSecondDoor3.lua | 12 ++++++++---- data/levels/scripts/openSecondDoor4.lua | 12 ++++++++---- data/levels/scripts/openThirdDoor.lua | 12 ++++++++---- data/levels/scripts/resetBox.lua | 8 +++++--- data/levels/scripts/resetPlayer.lua | 8 +++++--- data/levels/scripts/sunStart.lua | 6 ++++-- game/trigger.cc | 13 +++++++++---- 12 files changed, 83 insertions(+), 42 deletions(-) diff --git a/data/levels/scripts/Template.lua b/data/levels/scripts/Template.lua index 47effab..390df3d 100644 --- a/data/levels/scripts/Template.lua +++ b/data/levels/scripts/Template.lua @@ -6,7 +6,7 @@ if(global.triggeredSCRIPTNAMEUndo == nil) then global.triggeredSCRIPTNAMEUndo = false end -function trigger(objectToChange) +function trigger(objectToChange, printDebug) if(global.triggeredSCRIPTNAME == false) then if(not level) then print("No level found in Lua!") @@ -16,11 +16,13 @@ function trigger(objectToChange) --enter the scripts code here and replace all occurences of SCRIPTNAME with the name of the script. global.triggeredSCRIPTNAME = true - print("SCRIPTNAME") + if(printDebug) then + print("SCRIPTNAME") + end end end -function triggerUndo(objectToChange) +function triggerUndo(objectToChange, printDebug) if(global.triggeredSCRIPTNAMEUndo == false) then if(not level) then print("No level found in Lua!") @@ -30,6 +32,8 @@ function triggerUndo(objectToChange) --enter the scripts undo code here global.triggeredSCRIPTNAMEUndo = true - print("SCRIPTNAMEUndo") + if(printDebug) then + print("SCRIPTNAMEUndo") + end end end diff --git a/data/levels/scripts/firstCheckpoint.lua b/data/levels/scripts/firstCheckpoint.lua index 8231bfd..5509027 100644 --- a/data/levels/scripts/firstCheckpoint.lua +++ b/data/levels/scripts/firstCheckpoint.lua @@ -3,13 +3,15 @@ if(global.triggeredFristCheckpoint == nil) then global.triggeredFristCheckpoint = false end -function trigger(objectToChange) +function trigger(objectToChange, printDebug) if(global.triggeredFristCheckpoint == false) then if(not level) then print("No level found in Lua!") return end global.triggeredFristCheckpoint = true - print("firstCheckpoint") + if(printDebug) then + print("firstCheckpoint") + end end end diff --git a/data/levels/scripts/openFirstDoor.lua b/data/levels/scripts/openFirstDoor.lua index 44d95f4..1b267e5 100644 --- a/data/levels/scripts/openFirstDoor.lua +++ b/data/levels/scripts/openFirstDoor.lua @@ -6,7 +6,7 @@ if(global.triggeredOpenFirstDoorUndo == nil) then global.triggeredOpenFirstDoorUndo = true end -function trigger(objectToChange) +function trigger(objectToChange, printDebug) if(global.triggeredOpenFirstDoor == false) then if(not level) then print("No level found in Lua!") @@ -22,11 +22,13 @@ function trigger(objectToChange) global.triggeredOpenFirstDoorUndo = false global.triggeredOpenFirstDoor = true - print("openFirstDoor") + if (printDebug) then + print("openFirstDoor") + end end end -function triggerUndo(objectToChange) +function triggerUndo(objectToChange, printDebug) if(global.triggeredOpenFirstDoorUndo == false) then if(not level) then print("No level found in Lua!") @@ -42,6 +44,8 @@ function triggerUndo(objectToChange) global.triggeredOpenFirstDoor = false global.triggeredOpenFirstDoorUndo = true - print("openFirstDoorUndo") + if(printDebug) then + print("openFirstDoorUndo") + end end end diff --git a/data/levels/scripts/openSecondDoor1.lua b/data/levels/scripts/openSecondDoor1.lua index e7bd2d3..0e6b805 100644 --- a/data/levels/scripts/openSecondDoor1.lua +++ b/data/levels/scripts/openSecondDoor1.lua @@ -6,7 +6,7 @@ if(global.triggeredOpenSecondDoor1Undo == nil) then global.triggeredOpenSecondDoor1Undo = true end -function trigger(objectToChange) +function trigger(objectToChange, printDebug) if(global.triggeredOpenSecondDoor1 == false) then if(not level) then print("No level found in Lua!") @@ -30,11 +30,13 @@ function trigger(objectToChange) local zPos = 54.5 level:preloadLightPosition(xPos, yPos, zPos) level:addLightByParameters(0.2, 0.9, 0.0, 4.0, -2.0, 1.3, 2.0) - print("openSecondDoor1") + if(printDebug) then + print("openSecondDoor1") + end end end -function triggerUndo(objectToChange) +function triggerUndo(objectToChange, printDebug) if(global.triggeredOpenSecondDoor1Undo == false) then if(not level) then print("No level found in Lua!") @@ -49,6 +51,8 @@ function triggerUndo(objectToChange) level:deleteFourLights() global.triggeredOpenSecondDoor1Undo = true - print("openSecondDoor1Undo") + if(printDebug) then + print("openSecondDoor1Undo") + end end end diff --git a/data/levels/scripts/openSecondDoor2.lua b/data/levels/scripts/openSecondDoor2.lua index c7c0407..213c0b6 100644 --- a/data/levels/scripts/openSecondDoor2.lua +++ b/data/levels/scripts/openSecondDoor2.lua @@ -6,7 +6,7 @@ if(global.triggeredOpenSecondDoor2Undo == nil) then global.triggeredOpenSecondDoor2Undo = true end -function trigger(objectToChange) +function trigger(objectToChange, printDebug) if(global.triggeredOpenSecondDoor2 == false) then if(not level) then print("No level found in Lua!") @@ -30,11 +30,13 @@ function trigger(objectToChange) local zPos = 26.5 level:preloadLightPosition(xPos, yPos, zPos) level:addLightByParameters(0.2, 0.9, 0.0, 4.0, -2.0, 1.3, 2.0) - print("openSecondDoor2") + if(printDebug) then + print("openSecondDoor2") + end end end -function triggerUndo(objectToChange) +function triggerUndo(objectToChange, printDebug) if(global.triggeredOpenSecondDoor2Undo == false) then if(not level) then print("No level found in Lua!") @@ -49,6 +51,8 @@ function triggerUndo(objectToChange) level:deleteFourLights() global.triggeredOpenSecondDoor2Undo = true - print("openSecondDoor2Undo") + if(printDebug) then + print("openSecondDoor2Undo") + end end end diff --git a/data/levels/scripts/openSecondDoor3.lua b/data/levels/scripts/openSecondDoor3.lua index 845d578..8b7c3b0 100644 --- a/data/levels/scripts/openSecondDoor3.lua +++ b/data/levels/scripts/openSecondDoor3.lua @@ -6,7 +6,7 @@ if(global.triggeredOpenSecondDoor3Undo == nil) then global.triggeredOpenSecondDoor3Undo = true end -function trigger(objectToChange) +function trigger(objectToChange, printDebug) if(global.triggeredOpenSecondDoor3 == false) then if(not level) then print("No level found in Lua!") @@ -30,11 +30,13 @@ function trigger(objectToChange) local zPos = 26.5 level:preloadLightPosition(xPos, yPos, zPos) level:addLightByParameters(0.2, 0.9, 0.0, 4.0, -2.0, 1.3, 2.0) - print("openSecondDoor3") + if(printDebug) then + print("openSecondDoor3") + end end end -function triggerUndo(objectToChange) +function triggerUndo(objectToChange, printDebug) if(global.triggeredOpenSecondDoor3Undo == false) then if(not level) then print("No level found in Lua!") @@ -49,6 +51,8 @@ function triggerUndo(objectToChange) level:deleteFourLights() global.triggeredOpenSecondDoor3Undo = true - print("openSecondDoor3Undo") + if(printDebug) then + print("openSecondDoor3Undo") + end end end diff --git a/data/levels/scripts/openSecondDoor4.lua b/data/levels/scripts/openSecondDoor4.lua index 1b6c287..c979fc5 100644 --- a/data/levels/scripts/openSecondDoor4.lua +++ b/data/levels/scripts/openSecondDoor4.lua @@ -6,7 +6,7 @@ if(global.triggeredOpenSecondDoor4Undo == nil) then global.triggeredOpenSecondDoor4Undo = true end -function trigger(objectToChange) +function trigger(objectToChange, printDebug) if(global.triggeredOpenSecondDoor4 == false) then if(not level) then print("No level found in Lua!") @@ -39,11 +39,13 @@ function trigger(objectToChange) local zPos = 54.5 level:preloadLightPosition(xPos, yPos, zPos) level:addLightByParameters(0.2, 0.9, 0.0, 4.0, -2.0, 1.3, 2.0) - print("openSecondDoor4") + if(printDebug) then + print("openSecondDoor4") + end end end -function triggerUndo(objectToChange) +function triggerUndo(objectToChange, printDebug) if(global.triggeredOpenSecondDoor4Undo == false) then if(not level) then print("No level found in Lua!") @@ -58,6 +60,8 @@ function triggerUndo(objectToChange) level:deleteFourLights() global.triggeredOpenSecondDoor4Undo = true - print("openSecondDoor4Undo") + if(printDebug) then + print("openSecondDoor4Undo") + end end end diff --git a/data/levels/scripts/openThirdDoor.lua b/data/levels/scripts/openThirdDoor.lua index 69f3120..b86f35a 100644 --- a/data/levels/scripts/openThirdDoor.lua +++ b/data/levels/scripts/openThirdDoor.lua @@ -6,7 +6,7 @@ if(global.triggeredOpenThirdDoorUndo == nil) then global.triggeredOpenThirdDoorUndo = true end -function trigger(objectToChange) +function trigger(objectToChange, printDebug) if(global.triggeredOpenThirdDoor == false) then if(not level) then print("No level found in Lua!") @@ -22,11 +22,13 @@ function trigger(objectToChange) global.triggeredOpenThirdDoorUndo = false global.triggeredOpenThirdDoor = true - print("openThirdDoor") + if(printDebug) then + print("openThirdDoor") + end end end -function triggerUndo(objectToChange) +function triggerUndo(objectToChange, printDebug) if(global.triggeredOpenThirdDoorUndo == false) then if(not level) then print("No level found in Lua!") @@ -42,6 +44,8 @@ function triggerUndo(objectToChange) global.triggeredOpenThirdDoor = false global.triggeredOpenThirdDoorUndo = true - print("openThirdDoorUndo") + if(printDebug) then + print("openThirdDoorUndo") + end end end diff --git a/data/levels/scripts/resetBox.lua b/data/levels/scripts/resetBox.lua index 6fb37ef..4e46073 100644 --- a/data/levels/scripts/resetBox.lua +++ b/data/levels/scripts/resetBox.lua @@ -3,7 +3,7 @@ if(global.triggeredResetBox == nil) then global.triggeredResetBox = false end -function trigger(objectToChange) +function trigger(objectToChange, printDebug) if(global.triggeredResetBox == false) then if(not level) then print("No level found in Lua!") @@ -13,7 +13,9 @@ function trigger(objectToChange) local y = 22.5 local z =8.5 level:forceMove(x, y, z, objectToChange) - - print("reset box") + + if(printDebug) then + print("reset box") + end end end diff --git a/data/levels/scripts/resetPlayer.lua b/data/levels/scripts/resetPlayer.lua index 525e8d6..7308b92 100644 --- a/data/levels/scripts/resetPlayer.lua +++ b/data/levels/scripts/resetPlayer.lua @@ -3,7 +3,7 @@ if(global.triggeredResetPlayer == nil) then global.triggeredResetPlayer = false end -function trigger(objectToChange) +function trigger(objectToChange, printDebug) if(global.triggeredResetPlayer == false) then if(not level) then print("No level found in Lua!") @@ -27,7 +27,9 @@ function trigger(objectToChange) else level:resetPlayer() end - - print("reset player") + + if(printDebug) then + print("reset player") + end end end diff --git a/data/levels/scripts/sunStart.lua b/data/levels/scripts/sunStart.lua index f2d55fb..0a44507 100644 --- a/data/levels/scripts/sunStart.lua +++ b/data/levels/scripts/sunStart.lua @@ -3,7 +3,7 @@ if(global.triggeredSunStart == nil) then global.triggeredSunStart = false end -function trigger(objectToChange) +function trigger(objectToChange, printDebug) if(global.triggeredSunStart == false) then if(not level) then print("No level found in Lua!") @@ -14,6 +14,8 @@ function trigger(objectToChange) global.sunStartTime = time global.triggeredSunStart = true level:activateEndgame() - print("sunStart") + if(printDebug) then + print("sunStart") + end end end diff --git a/game/trigger.cc b/game/trigger.cc index 56cf321..f086779 100644 --- a/game/trigger.cc +++ b/game/trigger.cc @@ -27,6 +27,11 @@ Trigger::~Trigger(){ } void Trigger::triggerUpdate(){ + #ifdef SAXUM_DEBUG + bool printDebug = true; + #else + bool printDebug = false; + #endif if (isBigger && (glm::distance(object->getPosition(), position) > distance)) { int error = luaL_dofile(luaState, luaScript.c_str()); if (error != 0) { @@ -34,9 +39,9 @@ void Trigger::triggerUpdate(){ exit(-1); } if (undo){ - luabridge::getGlobal(luaState, "triggerUndo")(objectToChange); + luabridge::getGlobal(luaState, "triggerUndo")(objectToChange, printDebug); }else{ - luabridge::getGlobal(luaState, "trigger")(objectToChange); + luabridge::getGlobal(luaState, "trigger")(objectToChange, printDebug); } } else if (!isBigger && (glm::distance(object->getPosition(), position) < distance)) { @@ -46,9 +51,9 @@ void Trigger::triggerUpdate(){ exit(-1); } if (undo){ - luabridge::getGlobal(luaState, "triggerUndo")(objectToChange); + luabridge::getGlobal(luaState, "triggerUndo")(objectToChange, printDebug); }else{ - luabridge::getGlobal(luaState, "trigger")(objectToChange); + luabridge::getGlobal(luaState, "trigger")(objectToChange, printDebug); } } }