Antonis Kalou
Antonis Kalou

Reputation: 354

Luabind and class instances

I'm working on a data driven game engine and I'm seeking to integrate lua.

I seem to be having an issue binding instances of the current component class to a lua meta-table using luabind.

Here's the problematic code:

void BaseScriptComponent::createScriptObject()
{
    LuaStateManager* pStateManager = LuaStateManager::get();
    assert(pStateManager != nullptr);
    assert(luabind::type(m_scriptObject) != LUA_TNIL);

    // Get meta table
    luabind::object metaTableObject = pStateManager->getGlobalVars()[METATABLE_NAME];
    assert(luabind::type(metaTableObject) != LUA_TNIL);

    // Set __object to reference this class instance. 
    // Compilation failure due to this
    metaTableObject["__object"] = this;
    // Set meta table
    luabind::setmetatable(m_scriptObject, metaTableObject);
}

The compiler error is:

undefined reference to `bool luabind::get_back_reference<BaseScriptComponent*>(lua_State*, BaseScriptComponent* const&)' 

Any help is appreciated.

Upvotes: 3

Views: 200

Answers (0)

Related Questions