Exemplo n.º 1
0
static int GetProfilePermissions(lua_State * L) {
	if(lua_gettop(L) != 1) {
        luaL_error(L, "bad argument count to 'GetProfilePermissions' (1 expected, got %d)", lua_gettop(L));
        lua_settop(L, 0);
        lua_pushnil(L);
        return 1;
    }

    if(lua_type(L, 1) != LUA_TNUMBER) {
        luaL_checktype(L, 1, LUA_TNUMBER);

		lua_settop(L, 0);
		lua_pushnil(L);
        return 1;
    }

	uint16_t iProfile = (uint16_t)lua_tonumber(L, 1);
    
    // if the requested index is out of bounds return nil
    if(iProfile >= ProfileMan->iProfileCount) {
		lua_settop(L, 0);
		lua_pushnil(L);
        return 1;
	}

    PushProfilePermissions(L, iProfile);

    return 1;
}
Exemplo n.º 2
0
static int GetProfilePermissions(lua_State * pLua) {
	if(lua_gettop(pLua) != 1) {
        luaL_error(pLua, "bad argument count to 'GetProfilePermissions' (1 expected, got %d)", lua_gettop(pLua));
        lua_settop(pLua, 0);
        lua_pushnil(pLua);
        return 1;
    }

    if(lua_type(pLua, 1) != LUA_TNUMBER) {
        luaL_checktype(pLua, 1, LUA_TNUMBER);

		lua_settop(pLua, 0);
		lua_pushnil(pLua);
        return 1;
    }

#if LUA_VERSION_NUM < 503
	uint16_t iProfile = (uint16_t)lua_tonumber(pLua, 1);
#else
	uint16_t iProfile = (uint16_t)lua_tointeger(pLua, 1);
#endif

	lua_settop(pLua, 0);

    // if the requested index is out of bounds return nil
    if(iProfile >= ProfileManager::m_Ptr->m_ui16ProfileCount) {
		lua_pushnil(pLua);
        return 1;
	}

    PushProfilePermissions(pLua, iProfile);

    return 1;
}
Exemplo n.º 3
0
static void PushProfile(lua_State * L, const uint16_t &iProfile) {
	lua_checkstack(L, 3); // we need 3 (1 table, 2 id, 3 value) empty slots in stack, check it to be sure

    lua_newtable(L);
    int i = lua_gettop(L);

    lua_pushliteral(L, "sProfileName");
	lua_pushstring(L, ProfileMan->ProfilesTable[iProfile]->sName);
    lua_rawset(L, i);

    lua_pushliteral(L, "iProfileNumber");
	lua_pushnumber(L, iProfile);
    lua_rawset(L, i);

    lua_pushliteral(L, "tProfilePermissions");
	PushProfilePermissions(L, iProfile);
    lua_rawset(L, i);
}
Exemplo n.º 4
0
static void PushProfile(lua_State * pLua, const uint16_t iProfile) {
	lua_checkstack(pLua, 3); // we need 3 (1 table, 2 id, 3 value) empty slots in stack, check it to be sure

    lua_newtable(pLua);
    int i = lua_gettop(pLua);

    lua_pushliteral(pLua, "sProfileName");
	lua_pushstring(pLua, ProfileManager::m_Ptr->m_ppProfilesTable[iProfile]->m_sName);
    lua_rawset(pLua, i);

    lua_pushliteral(pLua, "iProfileNumber");
#if LUA_VERSION_NUM < 503
	lua_pushnumber(pLua, iProfile);
#else
	lua_pushinteger(pLua, iProfile);
#endif
    lua_rawset(pLua, i);

    lua_pushliteral(pLua, "tProfilePermissions");
	PushProfilePermissions(pLua, iProfile);
    lua_rawset(pLua, i);
}