/**\brief Get a planet by name or id */ int Planets_Lua::Get(lua_State* L){ int n = lua_gettop(L); // Number of arguments if( n!=1 ){ return luaL_error(L, "Got %d arguments expected 1 (id or name)", n); } Planet* p = NULL; if(lua_isstring(L,1)) { string name = (string)luaL_checkstring(L,1); p = (Planet*)Planets::Instance()->GetPlanet(name); if (p==NULL){ return luaL_error(L, "There is no planet by the name of '%s'", name.c_str()); } } else if(lua_isnumber(L,1)) { int id = (int)luaL_checkinteger(L,1); p = (Planet*)SpriteManager::Instance()->GetSpriteByID(id); if (p==NULL || p->GetDrawOrder() != DRAW_ORDER_PLANET){ return luaL_error(L, "There is no planet with ID %d", id); } } else { return luaL_error(L, "Cannot get planet with these arguments. Expected id or name."); } Lua::pushSprite(L,p); return 1; }