Example #1
0
void LuaLevelEngine::onBindAll()
{
    luabind::module(getNativeState())[
        Binding_Level_Class_PhysObj::bindToLua(),
        Binding_Level_Class_InAreaDetector::bindToLua(),
        Binding_Level_Class_PlayerPosDetector::bindToLua(),
        Binding_Level_ClassWrapper_LVL_Player::bindToLua(),
        Binding_Level_ClassWrapper_LVL_NPC::bindToLua(),
        Binding_Level_GlobalFuncs_Player::bindToLua(),
        Binding_Level_GlobalFuncs_NPC::bindToLua()
    ];

    {
        luabind::object _G = luabind::globals(getNativeState());
        if(luabind::type(_G["bases"]) != LUA_TTABLE){
            _G["bases"] = luabind::newtable(getNativeState());
        }

        _G["bases"]["npc"] = loadClassAPI(m_npcBaseClassPath);
        _G["bases"]["player"] = loadClassAPI(m_playerBaseClassPath);
    }

}
Example #2
0
void LuaLevelEngine::loadNPCClass(int id, const QString &path)
{
    if(shouldShutdown())
        return;

    luabind::object _G = luabind::globals(getNativeState());
    if(luabind::type(_G["npc_class_table"]) != LUA_TTABLE){
        _G["npc_class_table"] = luabind::newtable(getNativeState());
    }

    if(luabind::type(_G["npc_class_table"][id]) != LUA_TNIL)
        return;

    _G["npc_class_table"][id] = loadClassAPI(path);
}
Example #3
0
void LuaEngine::loadClassAPI(const QString &nameInGlobal, const QString &path)
{
    luabind::globals(L)[nameInGlobal.toStdString()] = loadClassAPI(path);
}