Original Post
Hi, I'm new in this forum and excuse me for my english.
I'm read the last thread about this topic seeking help for the problem of register a singleton/static methods (follow this link http://www.gamedev.net/community/forums/topic.asp?topic_id=469655) using luabind.
In that thread being a solution using a scope and I try to use these, but that
doesn't work.
my code is this.
Manager* Manager::mSingleton = 0;
Manager* Manager::getInstance()
{
if(mSingleton == 0)
mSingleton = new Manager;
return mSingleton ;
}
void Manager::registerManager(lua_State *rgt)
{
open(rgt);
module(rgt)[
class_("Manager")
.def("createRoot",&Manager::getCreateRoot)
.def("createBehavior",&Manager::getCreateBehavior)
.def("createSelector",&Manager::getCreateSelector)
.scope[
def("getInstance",&Manager::getInstance)
]
];
}
and the script
test = Manager:getInstance()
test:createRoot("Root")
when I try to run it, the application launch this message
"treeLua.lua:3:attempt to index global 'Manager'(a nil value)"
Where am I going wrong
thanks
I'm read the last thread about this topic seeking help for the problem of register a singleton/static methods (follow this link http://www.gamedev.net/community/forums/topic.asp?topic_id=469655) using luabind.
In that thread being a solution using a scope and I try to use these, but that
doesn't work.
my code is this.
Manager* Manager::mSingleton = 0;
Manager* Manager::getInstance()
{
if(mSingleton == 0)
mSingleton = new Manager;
return mSingleton ;
}
void Manager::registerManager(lua_State *rgt)
{
open(rgt);
module(rgt)[
class_
.def("createRoot",&Manager::getCreateRoot)
.def("createBehavior",&Manager::getCreateBehavior)
.def("createSelector",&Manager::getCreateSelector)
.scope[
def("getInstance",&Manager::getInstance)
]
];
}
and the script
test = Manager:getInstance()
test:createRoot("Root")
when I try to run it, the application launch this message
"treeLua.lua:3:attempt to index global 'Manager'(a nil value)"
Where am I going wrong
thanks