void LuaPlayerBase::Register(kaguya::State& state)
{
    state["PlayerBase"].setClass(kaguya::UserdataMetatable<LuaPlayerBase>()
                                   .addFunction("GetName", &LuaPlayerBase::GetName)
                                   .addFunction("GetNation", &LuaPlayerBase::GetNation)
                                   .addFunction("GetTeam", &LuaPlayerBase::GetTeam)
                                   .addFunction("GetColor", &LuaPlayerBase::GetColor)
                                   .addFunction("IsFree", &LuaPlayerBase::IsFree)
                                   .addFunction("IsHuman", &LuaPlayerBase::IsHuman)
                                   .addFunction("IsAI", &LuaPlayerBase::IsAI)
                                   .addFunction("IsClosed", &LuaPlayerBase::IsClosed)
                                   .addFunction("GetAILevel", &LuaPlayerBase::GetAILevel));

#pragma region ConstDefs
#define ADD_LUA_CONST(name) state[#name] = name

    ADD_LUA_CONST(NAT_AFRICANS);
    ADD_LUA_CONST(NAT_JAPANESE);
    ADD_LUA_CONST(NAT_ROMANS);
    ADD_LUA_CONST(NAT_VIKINGS);
    ADD_LUA_CONST(NAT_BABYLONIANS);

    ADD_LUA_CONST(TM_NOTEAM);
    ADD_LUA_CONST(TM_RANDOMTEAM);
    ADD_LUA_CONST(TM_RANDOMTEAM2);
    ADD_LUA_CONST(TM_RANDOMTEAM3);
    ADD_LUA_CONST(TM_RANDOMTEAM4);
    ADD_LUA_CONST(TM_TEAM1);
    ADD_LUA_CONST(TM_TEAM2);
    ADD_LUA_CONST(TM_TEAM3);
    ADD_LUA_CONST(TM_TEAM4);

#undef ADD_LUA_CONST
#pragma endregion ConstDefs
}
Пример #2
0
void LuaInterfaceSettings::Register(kaguya::State& state)
{
    state["RTTRSettings"].setClass(kaguya::ClassMetatable<LuaInterfaceSettings, LuaInterfaceBase>()
        .addMemberFunction("GetPlayerCount", &LuaInterfaceSettings::GetPlayerCount)
        .addMemberFunction("GetPlayer", &LuaInterfaceSettings::GetPlayer)
        .addMemberFunction("SetAddon", &LuaInterfaceSettings::SetAddon)
        .addMemberFunction("SetAddon", &LuaInterfaceSettings::SetBoolAddon)
        .addMemberFunction("ResetAddons", &LuaInterfaceSettings::ResetAddons)
        .addMemberFunction("SetGameSettings", &LuaInterfaceSettings::SetGameSettings)
        );

    state["AddonId"].setClass(kaguya::ClassMetatable<AddonId>());

    for(unsigned i = 0; i < AddonId::count_; ++i)
    {
        AddonId id = AddonId::type_(AddonId::values_()[i]);
        state[std::string("ADDON_") + id.toString()] = id;
    }

#pragma region ConstDefs
#define ADD_LUA_CONST(name) state[#name] = name

    ADD_LUA_CONST(GS_VERYSLOW);
    ADD_LUA_CONST(GS_SLOW);
    ADD_LUA_CONST(GS_NORMAL);
    ADD_LUA_CONST(GS_FAST);
    ADD_LUA_CONST(GS_VERYFAST);

    ADD_LUA_CONST(GO_NONE);
    ADD_LUA_CONST(GO_CONQUER3_4);
    ADD_LUA_CONST(GO_TOTALDOMINATION);

    ADD_LUA_CONST(SWR_VLOW);
    ADD_LUA_CONST(SWR_LOW);
    ADD_LUA_CONST(SWR_NORMAL);
    ADD_LUA_CONST(SWR_ALOT);

    ADD_LUA_CONST(EXP_DISABLED);
    ADD_LUA_CONST(EXP_CLASSIC);
    ADD_LUA_CONST(EXP_FOGOFWAR);
    ADD_LUA_CONST(EXP_FOGOFWARE_EXPLORED);

#undef ADD_LUA_CONST
#pragma endregion ConstDefs
}