Give the luaState a proper name.
This commit is contained in:
parent
efa151aa73
commit
1742d83d4b
16
trigger.cc
16
trigger.cc
@ -1,14 +1,14 @@
|
||||
#include "trigger.hh"
|
||||
|
||||
Trigger::Trigger(glm::vec3 position, float distance, bool isBigger, Object* object, std::string luaScript, lua_State* L, int objectToChange, std::string scriptPath) {
|
||||
Trigger::Trigger(glm::vec3 position, float distance, bool isBigger, Object* object, std::string luaScript, lua_State* luaState, int objectToChange, std::string scriptPath) {
|
||||
this->position=position;
|
||||
this->distance=distance;
|
||||
this->isBigger=isBigger;
|
||||
this->object=object;
|
||||
this->luaScript= scriptPath + luaScript;
|
||||
this->L = L;
|
||||
if(L == nullptr){
|
||||
printf("L is NULL in trigger!\n");
|
||||
this->luaState = luaState;
|
||||
if(luaState == nullptr){
|
||||
printf("The Lua state is NULL in trigger!\n");
|
||||
}
|
||||
this->objectToChange = objectToChange;
|
||||
}
|
||||
@ -21,12 +21,12 @@ Trigger::~Trigger(){
|
||||
|
||||
void Trigger::triggerUpdate(){
|
||||
if (isBigger && (glm::distance(object->getPosition(), position) > distance)) {
|
||||
luaL_dofile(L, luaScript.c_str());
|
||||
luabridge::getGlobal(L, "trigger")(objectToChange);
|
||||
luaL_dofile(luaState, luaScript.c_str());
|
||||
luabridge::getGlobal(luaState, "trigger")(objectToChange);
|
||||
}
|
||||
else if (!isBigger && (glm::distance(object->getPosition(), position) < distance)) {
|
||||
luaL_dofile(L, luaScript.c_str());
|
||||
luabridge::getGlobal(L, "trigger")(objectToChange);
|
||||
luaL_dofile(luaState, luaScript.c_str());
|
||||
luabridge::getGlobal(luaState, "trigger")(objectToChange);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ class Trigger {
|
||||
bool isBigger;
|
||||
Object* object;
|
||||
std::string luaScript;
|
||||
lua_State* L;
|
||||
lua_State* luaState;
|
||||
int objectToChange;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user