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
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
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
if(printDebug) then
print("SCRIPTNAMEUndo")
end
end
end

View File

@ -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
if(printDebug) then
print("firstCheckpoint")
end
end
end

View File

@ -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
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
if(printDebug) then
print("openFirstDoorUndo")
end
end
end

View File

@ -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)
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
if(printDebug) then
print("openSecondDoor1Undo")
end
end
end

View File

@ -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)
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
if(printDebug) then
print("openSecondDoor2Undo")
end
end
end

View File

@ -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)
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
if(printDebug) then
print("openSecondDoor3Undo")
end
end
end

View File

@ -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)
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
if(printDebug) then
print("openSecondDoor4Undo")
end
end
end

View File

@ -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
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
if(printDebug) then
print("openThirdDoorUndo")
end
end
end

View File

@ -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!")
@ -14,6 +14,8 @@ function trigger(objectToChange)
local z =8.5
level:forceMove(x, y, z, objectToChange)
if(printDebug) then
print("reset box")
end
end
end

View File

@ -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!")
@ -28,6 +28,8 @@ function trigger(objectToChange)
level:resetPlayer()
end
if(printDebug) then
print("reset player")
end
end
end

View File

@ -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()
if(printDebug) then
print("sunStart")
end
end
end

View File

@ -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);
}
}
}