Removing debug output from lua scripts for release builds.

This commit is contained in:
Faerbit 2015-03-15 18:46:44 +01:00
parent 48d9f173f3
commit 857fc76c40
12 changed files with 83 additions and 42 deletions

View File

@ -6,7 +6,7 @@ if(global.triggeredSCRIPTNAMEUndo == nil) then
global.triggeredSCRIPTNAMEUndo = false global.triggeredSCRIPTNAMEUndo = false
end end
function trigger(objectToChange) function trigger(objectToChange, printDebug)
if(global.triggeredSCRIPTNAME == false) then if(global.triggeredSCRIPTNAME == false) then
if(not level) then if(not level) then
print("No level found in Lua!") 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. --enter the scripts code here and replace all occurences of SCRIPTNAME with the name of the script.
global.triggeredSCRIPTNAME = true global.triggeredSCRIPTNAME = true
print("SCRIPTNAME") if(printDebug) then
print("SCRIPTNAME")
end
end end
end end
function triggerUndo(objectToChange) function triggerUndo(objectToChange, printDebug)
if(global.triggeredSCRIPTNAMEUndo == false) then if(global.triggeredSCRIPTNAMEUndo == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
@ -30,6 +32,8 @@ function triggerUndo(objectToChange)
--enter the scripts undo code here --enter the scripts undo code here
global.triggeredSCRIPTNAMEUndo = true global.triggeredSCRIPTNAMEUndo = true
print("SCRIPTNAMEUndo") if(printDebug) then
print("SCRIPTNAMEUndo")
end
end end
end end

View File

@ -3,13 +3,15 @@ if(global.triggeredFristCheckpoint == nil) then
global.triggeredFristCheckpoint = false global.triggeredFristCheckpoint = false
end end
function trigger(objectToChange) function trigger(objectToChange, printDebug)
if(global.triggeredFristCheckpoint == false) then if(global.triggeredFristCheckpoint == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
return return
end end
global.triggeredFristCheckpoint = true global.triggeredFristCheckpoint = true
print("firstCheckpoint") if(printDebug) then
print("firstCheckpoint")
end
end end
end end

View File

@ -6,7 +6,7 @@ if(global.triggeredOpenFirstDoorUndo == nil) then
global.triggeredOpenFirstDoorUndo = true global.triggeredOpenFirstDoorUndo = true
end end
function trigger(objectToChange) function trigger(objectToChange, printDebug)
if(global.triggeredOpenFirstDoor == false) then if(global.triggeredOpenFirstDoor == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
@ -22,11 +22,13 @@ function trigger(objectToChange)
global.triggeredOpenFirstDoorUndo = false global.triggeredOpenFirstDoorUndo = false
global.triggeredOpenFirstDoor = true global.triggeredOpenFirstDoor = true
print("openFirstDoor") if (printDebug) then
print("openFirstDoor")
end
end end
end end
function triggerUndo(objectToChange) function triggerUndo(objectToChange, printDebug)
if(global.triggeredOpenFirstDoorUndo == false) then if(global.triggeredOpenFirstDoorUndo == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
@ -42,6 +44,8 @@ function triggerUndo(objectToChange)
global.triggeredOpenFirstDoor = false global.triggeredOpenFirstDoor = false
global.triggeredOpenFirstDoorUndo = true global.triggeredOpenFirstDoorUndo = true
print("openFirstDoorUndo") if(printDebug) then
print("openFirstDoorUndo")
end
end end
end end

View File

@ -6,7 +6,7 @@ if(global.triggeredOpenSecondDoor1Undo == nil) then
global.triggeredOpenSecondDoor1Undo = true global.triggeredOpenSecondDoor1Undo = true
end end
function trigger(objectToChange) function trigger(objectToChange, printDebug)
if(global.triggeredOpenSecondDoor1 == false) then if(global.triggeredOpenSecondDoor1 == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
@ -30,11 +30,13 @@ function trigger(objectToChange)
local zPos = 54.5 local zPos = 54.5
level:preloadLightPosition(xPos, yPos, zPos) level:preloadLightPosition(xPos, yPos, zPos)
level:addLightByParameters(0.2, 0.9, 0.0, 4.0, -2.0, 1.3, 2.0) 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
end end
function triggerUndo(objectToChange) function triggerUndo(objectToChange, printDebug)
if(global.triggeredOpenSecondDoor1Undo == false) then if(global.triggeredOpenSecondDoor1Undo == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
@ -49,6 +51,8 @@ function triggerUndo(objectToChange)
level:deleteFourLights() level:deleteFourLights()
global.triggeredOpenSecondDoor1Undo = true global.triggeredOpenSecondDoor1Undo = true
print("openSecondDoor1Undo") if(printDebug) then
print("openSecondDoor1Undo")
end
end end
end end

View File

@ -6,7 +6,7 @@ if(global.triggeredOpenSecondDoor2Undo == nil) then
global.triggeredOpenSecondDoor2Undo = true global.triggeredOpenSecondDoor2Undo = true
end end
function trigger(objectToChange) function trigger(objectToChange, printDebug)
if(global.triggeredOpenSecondDoor2 == false) then if(global.triggeredOpenSecondDoor2 == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
@ -30,11 +30,13 @@ function trigger(objectToChange)
local zPos = 26.5 local zPos = 26.5
level:preloadLightPosition(xPos, yPos, zPos) level:preloadLightPosition(xPos, yPos, zPos)
level:addLightByParameters(0.2, 0.9, 0.0, 4.0, -2.0, 1.3, 2.0) 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
end end
function triggerUndo(objectToChange) function triggerUndo(objectToChange, printDebug)
if(global.triggeredOpenSecondDoor2Undo == false) then if(global.triggeredOpenSecondDoor2Undo == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
@ -49,6 +51,8 @@ function triggerUndo(objectToChange)
level:deleteFourLights() level:deleteFourLights()
global.triggeredOpenSecondDoor2Undo = true global.triggeredOpenSecondDoor2Undo = true
print("openSecondDoor2Undo") if(printDebug) then
print("openSecondDoor2Undo")
end
end end
end end

View File

@ -6,7 +6,7 @@ if(global.triggeredOpenSecondDoor3Undo == nil) then
global.triggeredOpenSecondDoor3Undo = true global.triggeredOpenSecondDoor3Undo = true
end end
function trigger(objectToChange) function trigger(objectToChange, printDebug)
if(global.triggeredOpenSecondDoor3 == false) then if(global.triggeredOpenSecondDoor3 == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
@ -30,11 +30,13 @@ function trigger(objectToChange)
local zPos = 26.5 local zPos = 26.5
level:preloadLightPosition(xPos, yPos, zPos) level:preloadLightPosition(xPos, yPos, zPos)
level:addLightByParameters(0.2, 0.9, 0.0, 4.0, -2.0, 1.3, 2.0) 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
end end
function triggerUndo(objectToChange) function triggerUndo(objectToChange, printDebug)
if(global.triggeredOpenSecondDoor3Undo == false) then if(global.triggeredOpenSecondDoor3Undo == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
@ -49,6 +51,8 @@ function triggerUndo(objectToChange)
level:deleteFourLights() level:deleteFourLights()
global.triggeredOpenSecondDoor3Undo = true global.triggeredOpenSecondDoor3Undo = true
print("openSecondDoor3Undo") if(printDebug) then
print("openSecondDoor3Undo")
end
end end
end end

View File

@ -6,7 +6,7 @@ if(global.triggeredOpenSecondDoor4Undo == nil) then
global.triggeredOpenSecondDoor4Undo = true global.triggeredOpenSecondDoor4Undo = true
end end
function trigger(objectToChange) function trigger(objectToChange, printDebug)
if(global.triggeredOpenSecondDoor4 == false) then if(global.triggeredOpenSecondDoor4 == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
@ -39,11 +39,13 @@ function trigger(objectToChange)
local zPos = 54.5 local zPos = 54.5
level:preloadLightPosition(xPos, yPos, zPos) level:preloadLightPosition(xPos, yPos, zPos)
level:addLightByParameters(0.2, 0.9, 0.0, 4.0, -2.0, 1.3, 2.0) 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
end end
function triggerUndo(objectToChange) function triggerUndo(objectToChange, printDebug)
if(global.triggeredOpenSecondDoor4Undo == false) then if(global.triggeredOpenSecondDoor4Undo == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
@ -58,6 +60,8 @@ function triggerUndo(objectToChange)
level:deleteFourLights() level:deleteFourLights()
global.triggeredOpenSecondDoor4Undo = true global.triggeredOpenSecondDoor4Undo = true
print("openSecondDoor4Undo") if(printDebug) then
print("openSecondDoor4Undo")
end
end end
end end

View File

@ -6,7 +6,7 @@ if(global.triggeredOpenThirdDoorUndo == nil) then
global.triggeredOpenThirdDoorUndo = true global.triggeredOpenThirdDoorUndo = true
end end
function trigger(objectToChange) function trigger(objectToChange, printDebug)
if(global.triggeredOpenThirdDoor == false) then if(global.triggeredOpenThirdDoor == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
@ -22,11 +22,13 @@ function trigger(objectToChange)
global.triggeredOpenThirdDoorUndo = false global.triggeredOpenThirdDoorUndo = false
global.triggeredOpenThirdDoor = true global.triggeredOpenThirdDoor = true
print("openThirdDoor") if(printDebug) then
print("openThirdDoor")
end
end end
end end
function triggerUndo(objectToChange) function triggerUndo(objectToChange, printDebug)
if(global.triggeredOpenThirdDoorUndo == false) then if(global.triggeredOpenThirdDoorUndo == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
@ -42,6 +44,8 @@ function triggerUndo(objectToChange)
global.triggeredOpenThirdDoor = false global.triggeredOpenThirdDoor = false
global.triggeredOpenThirdDoorUndo = true global.triggeredOpenThirdDoorUndo = true
print("openThirdDoorUndo") if(printDebug) then
print("openThirdDoorUndo")
end
end end
end end

View File

@ -3,7 +3,7 @@ if(global.triggeredResetBox == nil) then
global.triggeredResetBox = false global.triggeredResetBox = false
end end
function trigger(objectToChange) function trigger(objectToChange, printDebug)
if(global.triggeredResetBox == false) then if(global.triggeredResetBox == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
@ -13,7 +13,9 @@ function trigger(objectToChange)
local y = 22.5 local y = 22.5
local z =8.5 local z =8.5
level:forceMove(x, y, z, objectToChange) level:forceMove(x, y, z, objectToChange)
print("reset box") if(printDebug) then
print("reset box")
end
end end
end end

View File

@ -3,7 +3,7 @@ if(global.triggeredResetPlayer == nil) then
global.triggeredResetPlayer = false global.triggeredResetPlayer = false
end end
function trigger(objectToChange) function trigger(objectToChange, printDebug)
if(global.triggeredResetPlayer == false) then if(global.triggeredResetPlayer == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
@ -27,7 +27,9 @@ function trigger(objectToChange)
else else
level:resetPlayer() level:resetPlayer()
end end
print("reset player") if(printDebug) then
print("reset player")
end
end end
end end

View File

@ -3,7 +3,7 @@ if(global.triggeredSunStart == nil) then
global.triggeredSunStart = false global.triggeredSunStart = false
end end
function trigger(objectToChange) function trigger(objectToChange, printDebug)
if(global.triggeredSunStart == false) then if(global.triggeredSunStart == false) then
if(not level) then if(not level) then
print("No level found in Lua!") print("No level found in Lua!")
@ -14,6 +14,8 @@ function trigger(objectToChange)
global.sunStartTime = time global.sunStartTime = time
global.triggeredSunStart = true global.triggeredSunStart = true
level:activateEndgame() level:activateEndgame()
print("sunStart") if(printDebug) then
print("sunStart")
end
end end
end end

View File

@ -27,6 +27,11 @@ Trigger::~Trigger(){
} }
void Trigger::triggerUpdate(){ void Trigger::triggerUpdate(){
#ifdef SAXUM_DEBUG
bool printDebug = true;
#else
bool printDebug = false;
#endif
if (isBigger && (glm::distance(object->getPosition(), position) > distance)) { if (isBigger && (glm::distance(object->getPosition(), position) > distance)) {
int error = luaL_dofile(luaState, luaScript.c_str()); int error = luaL_dofile(luaState, luaScript.c_str());
if (error != 0) { if (error != 0) {
@ -34,9 +39,9 @@ void Trigger::triggerUpdate(){
exit(-1); exit(-1);
} }
if (undo){ if (undo){
luabridge::getGlobal(luaState, "triggerUndo")(objectToChange); luabridge::getGlobal(luaState, "triggerUndo")(objectToChange, printDebug);
}else{ }else{
luabridge::getGlobal(luaState, "trigger")(objectToChange); luabridge::getGlobal(luaState, "trigger")(objectToChange, printDebug);
} }
} }
else if (!isBigger && (glm::distance(object->getPosition(), position) < distance)) { else if (!isBigger && (glm::distance(object->getPosition(), position) < distance)) {
@ -46,9 +51,9 @@ void Trigger::triggerUpdate(){
exit(-1); exit(-1);
} }
if (undo){ if (undo){
luabridge::getGlobal(luaState, "triggerUndo")(objectToChange); luabridge::getGlobal(luaState, "triggerUndo")(objectToChange, printDebug);
}else{ }else{
luabridge::getGlobal(luaState, "trigger")(objectToChange); luabridge::getGlobal(luaState, "trigger")(objectToChange, printDebug);
} }
} }
} }