Give the luaState a proper name.

This commit is contained in:
Faerbit 2015-02-15 19:37:13 +01:00
parent efa151aa73
commit 1742d83d4b
2 changed files with 9 additions and 9 deletions

View File

@ -1,14 +1,14 @@
#include "trigger.hh" #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->position=position;
this->distance=distance; this->distance=distance;
this->isBigger=isBigger; this->isBigger=isBigger;
this->object=object; this->object=object;
this->luaScript= scriptPath + luaScript; this->luaScript= scriptPath + luaScript;
this->L = L; this->luaState = luaState;
if(L == nullptr){ if(luaState == nullptr){
printf("L is NULL in trigger!\n"); printf("The Lua state is NULL in trigger!\n");
} }
this->objectToChange = objectToChange; this->objectToChange = objectToChange;
} }
@ -21,12 +21,12 @@ 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(L, luaScript.c_str()); luaL_dofile(luaState, luaScript.c_str());
luabridge::getGlobal(L, "trigger")(objectToChange); luabridge::getGlobal(luaState, "trigger")(objectToChange);
} }
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(luaState, luaScript.c_str());
luabridge::getGlobal(L, "trigger")(objectToChange); luabridge::getGlobal(luaState, "trigger")(objectToChange);
} }
} }

View File

@ -25,7 +25,7 @@ class Trigger {
bool isBigger; bool isBigger;
Object* object; Object* object;
std::string luaScript; std::string luaScript;
lua_State* L; lua_State* luaState;
int objectToChange; int objectToChange;
}; };