Пример #1
0
/**\brief Get the Alliance of this planet
 */
int Planets_Lua::GetAlliance(lua_State* L){
	int n = lua_gettop(L);  // Number of arguments
	if (n == 1) {
		Planet* planet= checkPlanet(L,1);
		lua_pushstring(L, planet->GetAlliance()->GetName().c_str());
	} else {
		luaL_error(L, "Got %d arguments expected 1 (self)", n);
	}
	return 1;
}
Пример #2
0
/**\brief Get Landable boolean of this planet
 */
int Planets_Lua::GetLandable(lua_State* L){
	int n = lua_gettop(L);  // Number of arguments
	if (n == 1) {
		Planet* planet= checkPlanet(L,1);
		lua_pushboolean(L, planet->GetLandable() );
	} else {
		luaL_error(L, "Got %d arguments expected 1 (self)", n);
	}
	return 1;
}
Пример #3
0
/**\brief Get the Type of this planet
 */
int Planets_Lua::GetType(lua_State* L){
	int n = lua_gettop(L);  // Number of arguments
	if (n == 1) {
		Planet* planet= checkPlanet(L,1);
		lua_pushinteger(L, planet->GetDrawOrder());
	} else {
		luaL_error(L, "Got %d arguments expected 1 (self)", n);
	}
	return 1;
}
Пример #4
0
int Planets_Lua::GetMilitiaSize(lua_State* L){
	int n = lua_gettop(L);  // Number of arguments
	if (n == 1) {
		cPlanet** planet= checkPlanet(L,1);
		lua_pushnumber(L, (*planet)->GetMilitiaSize() );
	} else {
		luaL_error(L, "Got %d arguments expected 1 (self)", n); 
	}
	return 1;
}
Пример #5
0
/**\brief Get the Position of this planet
 */
int Planets_Lua::GetPosition(lua_State* L){
	int n = lua_gettop(L);  // Number of arguments
	if (n == 1) {
		Planet* planet= checkPlanet(L,1);
		lua_pushnumber(L, planet->GetWorldPosition().GetX() );
		lua_pushnumber(L, planet->GetWorldPosition().GetY() );
	} else {
		luaL_error(L, "Got %d arguments expected 1 (self)", n);
	}
	return 2;
}
Пример #6
0
/**\brief Lua callable function to set forbidden status
 */
int Planets_Lua::SetForbidden(lua_State* L){
        int n = lua_gettop(L);  // Number of arguments
        if (n == 2) {
                Planet* p = checkPlanet(L,1);
                if(p==NULL) return 0;
                int f = luaL_checkint (L, 2);
                (p)->SetForbidden( (f == 1) );
        } else {
                luaL_error(L, "Got %d arguments expected 2 (ship, forbidden)", n);
        }
        return 0;
}
Пример #7
0
/**\brief Lua callable function to get forbidden status
 */
int Planets_Lua::GetForbidden(lua_State* L){
        int n = lua_gettop(L);  // Number of arguments

        if (n == 1) {
                Planet* p = checkPlanet(L,1);
                if(p==NULL){
                        lua_pushnumber(L, 0 );
                        return 1;
                }
                lua_pushinteger(L, (int) ((p)->GetForbidden() ? 1 : 0) );
        }
        else {  
                luaL_error(L, "Got %d arguments expected 1 (self)", n);
        }
        return 1;
}
Пример #8
0
/**\brief Get the Outfits available at this planet
 */
int Planets_Lua::GetOutfits(lua_State* L){
	int n = lua_gettop(L);  // Number of arguments
	if (n == 1) {
		Planet* planet= checkPlanet(L,1);
		list<Outfit*> outfits = planet->GetOutfits();
		list<Outfit*>::iterator iter;
		lua_createtable(L, outfits.size(), 0);
		int newTable = lua_gettop(L);
		int index = 1;
		for(iter=outfits.begin();iter!=outfits.end();++iter,++index){
			lua_pushstring(L, (*iter)->GetName().c_str() );
			lua_rawseti(L, newTable, index);
		}
	} else {
		luaL_error(L, "Got %d arguments expected 1 (self)", n);
	}
	return 1;
}