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