Added an errorcheck when loading lua files.
This commit is contained in:
parent
eac0031b0a
commit
2c191c75a5
36
trigger.cc
36
trigger.cc
@ -27,22 +27,30 @@ Trigger::~Trigger(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Trigger::triggerUpdate(){
|
void Trigger::triggerUpdate(){
|
||||||
if (isBigger && (glm::distance(object->getPosition(), position) > distance)) {
|
if (isBigger && (glm::distance(object->getPosition(), position) > distance)) {
|
||||||
luaL_dofile(luaState, luaScript.c_str());
|
int error = luaL_dofile(luaState, luaScript.c_str());
|
||||||
if (undo){
|
if (error != 0) {
|
||||||
luabridge::getGlobal(luaState, "triggerUndo")(objectToChange);
|
std::cout << "Couldn't load file: " << this->luaScript << std::endl;
|
||||||
}else{
|
exit(-1);
|
||||||
luabridge::getGlobal(luaState, "trigger")(objectToChange);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (!isBigger && (glm::distance(object->getPosition(), position) < distance)) {
|
if (undo){
|
||||||
luaL_dofile(luaState, luaScript.c_str());
|
luabridge::getGlobal(luaState, "triggerUndo")(objectToChange);
|
||||||
if (undo){
|
}else{
|
||||||
luabridge::getGlobal(luaState, "triggerUndo")(objectToChange);
|
luabridge::getGlobal(luaState, "trigger")(objectToChange);
|
||||||
}else{
|
|
||||||
luabridge::getGlobal(luaState, "trigger")(objectToChange);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (!isBigger && (glm::distance(object->getPosition(), position) < distance)) {
|
||||||
|
int error = luaL_dofile(luaState, luaScript.c_str());
|
||||||
|
if (error != 0) {
|
||||||
|
std::cout << "Couldn't load file: " << this->luaScript << std::endl;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
if (undo){
|
||||||
|
luabridge::getGlobal(luaState, "triggerUndo")(objectToChange);
|
||||||
|
}else{
|
||||||
|
luabridge::getGlobal(luaState, "trigger")(objectToChange);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Trigger::deleteNotification(int deletedObjectIndex){
|
bool Trigger::deleteNotification(int deletedObjectIndex){
|
||||||
|
Loading…
Reference in New Issue
Block a user