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(){
|
||||
if (isBigger && (glm::distance(object->getPosition(), position) > distance)) {
|
||||
luaL_dofile(luaState, luaScript.c_str());
|
||||
if (undo){
|
||||
luabridge::getGlobal(luaState, "triggerUndo")(objectToChange);
|
||||
}else{
|
||||
luabridge::getGlobal(luaState, "trigger")(objectToChange);
|
||||
}
|
||||
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);
|
||||
}
|
||||
else if (!isBigger && (glm::distance(object->getPosition(), position) < distance)) {
|
||||
luaL_dofile(luaState, luaScript.c_str());
|
||||
if (undo){
|
||||
luabridge::getGlobal(luaState, "triggerUndo")(objectToChange);
|
||||
}else{
|
||||
luabridge::getGlobal(luaState, "trigger")(objectToChange);
|
||||
}
|
||||
if (undo){
|
||||
luabridge::getGlobal(luaState, "triggerUndo")(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){
|
||||
|
Loading…
Reference in New Issue
Block a user