lua/wrappers/game/lua_character.cpp
/**
	 * Sets the race of the character, nil will set to the unknown race.
	 *
	 * @param Race race The race to change to.
	 * @returns am.character This
	 */
Sets the race of the character, nil will set to the unknown race.
@param Race race The race to change to.
Sets the race of the character nil will set to the unknown race . @param Race race The race to change to .
int Character_race(lua_State *lua)
	{
		Character *obj = castUData<Character>(lua, 1);
		if (obj)
		{
			if (lua_gettop(lua) == 1)
			{
				Race *race = obj->getRace();
				if (race)
				{
					wrapRefObject<Race>(lua, obj->getRace());
				}
				else
				{
					wrapRefObject<Race>(lua, Engine::getEngine()->getUnknownRace());
				}
				return 1;
			}
			else if(lua_isnil(lua, 2))
			{
				obj->setRace(nullptr);
				lua_first(lua);
			}
			else
			{
				Race *race = nullptr;
				if (lua_type(lua, 2) == LUA_TSTRING)
				{
					race = Engine::getEngine()->getRace(lua_tostring(lua, 2));
				}
				else
				{
					race = castUData<Race>(lua, 2);
				}
				if (race)
				{
					obj->setRace(race);
					lua_first(lua);
				}
			}
			return LuaState::expectedArgs(lua, "race", 3, "string race_name", "Race race", "nil");
		}
		return LuaState::expectedContext(lua, "race", "am.character");
	}
int Character_race ( lua_State * lua ) { Character * obj = castUData < Character > ( lua , 1 ) ; if ( obj ) { if ( lua_gettop ( lua ) == 1 ) { Race * race = obj -> getRace ( ) ; if ( race ) { wrapRefObject < Race > ( lua , obj -> getRace ( ) ) ; } else { wrapRefObject < Race > ( lua , Engine :: getEngine ( ) -> getUnknownRace ( ) ) ; } return 1 ; } else if ( lua_isnil ( lua , 2 ) ) { obj -> setRace ( nullptr ) ; lua_first ( lua ) ; } else { Race * race = nullptr ; if ( lua_type ( lua , 2 ) == LUA_TSTRING ) { race = Engine :: getEngine ( ) -> getRace ( lua_tostring ( lua , 2 ) ) ; } else { race = castUData < Race > ( lua , 2 ) ; } if ( race ) { obj -> setRace ( race ) ; lua_first ( lua ) ; } } return LuaState :: expectedArgs ( lua , " " , 3 , " " , " " , " " ) ; } return LuaState :: expectedContext ( lua , " " , " " ) ; }
Sets the race of the character, nil will set to the unknown race.
Sets the race of the character nil will set to the unknown race .