moved the triggered/not triggered information to lua
This commit is contained in:
parent
2c0d4424a2
commit
ed6e257b69
@ -1,11 +1,18 @@
|
|||||||
function trigger(objectToChange)
|
if(triggeredDeleteObject == nil) then
|
||||||
if(not level) then
|
triggeredDeleteObject = false
|
||||||
print("No level found in Lua!")
|
end
|
||||||
return
|
function trigger(objectToChange)
|
||||||
end
|
if(triggeredDeleteObject == false) then
|
||||||
if(not physics) then
|
if(not level) then
|
||||||
print("No physics found in Lua!")
|
print("No level found in Lua!")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
level:deleteObject(objectToChange)
|
if(not physics) then
|
||||||
|
print("No physics found in Lua!")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
level:deleteObject(objectToChange)
|
||||||
|
triggeredDeleteObject = true
|
||||||
|
print("deleteObject")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,14 +1,20 @@
|
|||||||
function trigger(objectToChange)
|
if(triggeredDeleteRandomObject == nil) then
|
||||||
if(not level) then
|
triggeredDeleteRandomObject = false
|
||||||
print("No level found in Lua!")
|
end
|
||||||
return
|
function trigger(objectToChange)
|
||||||
end
|
if(triggeredDeleteRandomObject == false) then
|
||||||
if(not physics) then
|
if(not level) then
|
||||||
print("No physics found in Lua!")
|
print("No level found in Lua!")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
a = level:getObjectCount()
|
if(not physics) then
|
||||||
rand = math.random(0, a - 1)
|
print("No physics found in Lua!")
|
||||||
level:deleteObject(rand)
|
return
|
||||||
print("Triggered from Lua!")
|
end
|
||||||
|
a = level:getObjectCount()
|
||||||
|
rand = math.random(0, a - 1)
|
||||||
|
level:deleteObject(rand)
|
||||||
|
triggeredDeleteRandomObject = true
|
||||||
|
print("deleteRandomObject")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,7 +11,6 @@ Trigger::Trigger(glm::vec3 position, float distance, bool isBigger, Object* obje
|
|||||||
printf("L is NULL in trigger!\n");
|
printf("L is NULL in trigger!\n");
|
||||||
}
|
}
|
||||||
this->objectToChange = objectToChange;
|
this->objectToChange = objectToChange;
|
||||||
triggered = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Trigger::Trigger(){
|
Trigger::Trigger(){
|
||||||
@ -21,18 +20,14 @@ Trigger::~Trigger(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Trigger::triggerUpdate(){
|
void Trigger::triggerUpdate(){
|
||||||
if (!triggered){
|
|
||||||
if (isBigger && (glm::distance(object->getPosition(), position) > distance)) {
|
if (isBigger && (glm::distance(object->getPosition(), position) > distance)) {
|
||||||
luaL_dofile(L, luaScript.c_str());
|
luaL_dofile(L, luaScript.c_str());
|
||||||
luabridge::getGlobal(L, "trigger")(objectToChange);
|
luabridge::getGlobal(L, "trigger")(objectToChange);
|
||||||
triggered = true;
|
|
||||||
}
|
}
|
||||||
else if (!isBigger && (glm::distance(object->getPosition(), position) < distance)) {
|
else if (!isBigger && (glm::distance(object->getPosition(), position) < distance)) {
|
||||||
luaL_dofile(L, luaScript.c_str());
|
luaL_dofile(L, luaScript.c_str());
|
||||||
luabridge::getGlobal(L, "trigger")(objectToChange);
|
luabridge::getGlobal(L, "trigger")(objectToChange);
|
||||||
triggered = true;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Trigger::deleteNotification(int deletedObjectIndex){
|
bool Trigger::deleteNotification(int deletedObjectIndex){
|
||||||
|
@ -25,7 +25,6 @@ class Trigger {
|
|||||||
bool isBigger;
|
bool isBigger;
|
||||||
Object* object;
|
Object* object;
|
||||||
std::string luaScript;
|
std::string luaScript;
|
||||||
bool triggered;
|
|
||||||
lua_State* L;
|
lua_State* L;
|
||||||
int objectToChange;
|
int objectToChange;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user