[Add] Pilot:setFaction() added to Lua API.
This commit is contained in:
		
							parent
							
								
									4038b56ac6
								
							
						
					
					
						commit
						1edbf5b944
					
				| @ -77,5 +77,18 @@ | ||||
|    <location>Bar</location> | ||||
|    <planet>Omega Station</planet> | ||||
|   </avail> | ||||
| </mission> | ||||
|   <mission name="Operation Black Trinity"> | ||||
|     <lua>emp_collective05</lua> | ||||
|     <flags> | ||||
|       <unique>1</unique> | ||||
|     </flags> | ||||
|     <avail> | ||||
|       <cond>player.getFaction("Empire") > 5</cond> | ||||
|       <done>Collective Distraction</done> | ||||
|       <chance>100</chance> | ||||
|       <location>Bar</location> | ||||
|       <planet>Omega Station</planet> | ||||
|     </avail> | ||||
|   </mission> | ||||
| </Missions> | ||||
|  | ||||
| @ -12,7 +12,7 @@ | ||||
| #include "lluadef.h" | ||||
| #include "rng.h" | ||||
| #include "pilot.h" | ||||
| #include "pilot.h" | ||||
| #include "player.h" | ||||
| #include "llua_pilot.h" | ||||
| 
 | ||||
| static int pilotL_createmetatable(lua_State* L); | ||||
| @ -36,6 +36,7 @@ static int pilotL_rename(lua_State* L); | ||||
| static int pilotL_position(lua_State* L); | ||||
| static int pilotL_warp(lua_State* L); | ||||
| static int pilotL_broadcast(lua_State* L); | ||||
| static int pilotL_setFaction(lua_State* L); | ||||
| static const luaL_reg pilotL_methods[] = { | ||||
|   { "__eq",       pilotL_eq         }, | ||||
|   { "name",       pilotL_name       }, | ||||
| @ -44,6 +45,7 @@ static const luaL_reg pilotL_methods[] = { | ||||
|   { "pos",        pilotL_position   }, | ||||
|   { "warp",       pilotL_warp       }, | ||||
|   { "broadcast",  pilotL_broadcast  }, | ||||
|   { "setFaction", pilotL_setFaction }, | ||||
|   { 0, 0 } | ||||
| }; /**< Pilot metatable methods. */ | ||||
| 
 | ||||
| @ -508,3 +510,30 @@ static int pilotL_broadcast(lua_State* L) { | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|  * @fn  | ||||
|  */ | ||||
| static int pilotL_setFaction(lua_State* L) { | ||||
|   LLUA_MIN_ARGS(2); | ||||
|   Pilot* p; | ||||
|   LuaPilot* lp; | ||||
|   int fid; | ||||
|   char* faction; | ||||
| 
 | ||||
|   /* Parse parameters. */ | ||||
|   lp = lua_topilot(L, 1); | ||||
|   if(lua_isstring(L, 2)) | ||||
|     faction = (char*)lua_tostring(L,2); | ||||
|   else LLUA_INVALID_PARAMETER(); | ||||
| 
 | ||||
|   /* Get pilot/faction. */ | ||||
|   p = pilot_get(lp->pilot); | ||||
|   if(p == NULL) return 0; | ||||
|   fid = faction_get(faction); | ||||
| 
 | ||||
|   /* Set the new faction. */ | ||||
|   p->faction = fid; | ||||
| 
 | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Allanis
						Allanis