So I'm playing with binding Lua to C++ for class. I have an example which does the binding correctly. What I am trying to toy with now is sharing objects between Lua scripts which will be referenced by a name.
So I have a Badger class which is binded to Lua via LuaBadger. Now what I have attempted to do is make a BadgerManager class which gets called when the Lua script attempts to create a new Badger. It checks to see if the Badger is already created then returns that Badger. Probably pointless and going about it the wrong way but I'm just kind of playing around at this point.
Issue is that when I attempt to store and use a BadgerManager pointer in my LuaBadger class it is telling me unresolved external symbol. It has to be something with my use of static in the class. Although I'm apparently misunderstanding what I am doing. Any help on resolving the unresolved would be great. Thank!
BadgerManager (part of SimpleLua.h)
Excerpt from LuaBadger (below BadgerManager in SimpleLua.h)
Badger* GetBadger(const char* name)
Badger* b = 0;
list<Badger*>::iterator itr = badgerList.begin();
while(itr != badgerList.end())
b = (*itr);
(*b) = Badger(name);
If I comment out bm->GetBadger(name) everything compiles fine.
static BadgerManager* bm;
static int create_badger(lua_State* L)
const char* name = luaL_checkstring(L, 1);
b = (Badger*)lua_newuserdata(L, sizeof(Badger));
//(*b) = Badger(name);
b = bm->GetBadger(name);