![]() |
naev 0.12.6
|
Handles the Lua faction bindings. More...
#include "nlua_faction.h"#include "array.h"#include "faction.h"#include "nlua.h"#include "nlua_colour.h"#include "nlua_system.h"#include "nlua_tex.h"#include "nluadef.h"
Go to the source code of this file.
Functions | |
| static LuaFaction | luaL_validfactionSilent (lua_State *L, int ind) |
| static int | factionL_exists (lua_State *L) |
| Lua bindings to deal with factions. | |
| static int | factionL_get (lua_State *L) |
| Gets the faction based on its name. | |
| static int | factionL_getAll (lua_State *L) |
| Gets all the factions. | |
| static int | factionL_player (lua_State *L) |
| Gets the player's faction. | |
| static int | factionL_eq (lua_State *L) |
| __eq (equality) metamethod for factions. | |
| static int | factionL_name (lua_State *L) |
| Gets the faction's translated short name. | |
| static int | factionL_nameRaw (lua_State *L) |
| Gets the faction's raw / "real" (untranslated, internal) name. | |
| static int | factionL_longname (lua_State *L) |
| Gets the faction's translated long name. | |
| static int | factionL_areneutral (lua_State *L) |
| Checks to see if two factions are truly neutral with respect to each other. | |
| static int | factionL_areenemies (lua_State *L) |
| Checks to see if f is an enemy of e. | |
| static int | factionL_areallies (lua_State *L) |
| Checks to see if f is an ally of a. | |
| static int | factionL_usesHiddenJumps (lua_State *L) |
| Gets whether or not a faction uses hidden jumps. | |
| static int | factionL_hit (lua_State *L) |
| Modifies the player's standing with the faction. | |
| static int | factionL_hitTest (lua_State *L) |
| Simulates modifying the player's standing with a faction and computes how much would be changed. | |
| static int | factionL_reputationGlobal (lua_State *L) |
| Gets the player's global reputation with the faction. | |
| static int | factionL_reputationText (lua_State *L) |
| Gets the human readable standing text correpsonding (translated). | |
| static int | factionL_reputationDefault (lua_State *L) |
| Gets the player's default reputation with the faction. | |
| static int | factionL_setReputationGlobal (lua_State *L) |
| Overrides the player's faction global standing with a faction. Use sparingly as it overrites local standings at all systems. | |
| static int | factionL_applyLocalThreshold (lua_State *L) |
| Enforces the local threshold of a faction starting at a particular system. Meant to be used when computing faction hits from the faction standing Lua scripts. Not meant for use elsewhere. | |
| static int | factionL_enemies (lua_State *L) |
| Gets the enemies of the faction. | |
| static int | factionL_allies (lua_State *L) |
| Gets the allies of the faction. | |
| static int | factionL_logo (lua_State *L) |
| Gets the faction logo. | |
| static int | factionL_colour (lua_State *L) |
| Gets the faction colour. | |
| static int | factionL_isKnown (lua_State *L) |
| Checks to see if a faction is known by the player. | |
| static int | factionL_setKnown (lua_State *L) |
| Sets a faction's known state. | |
| static int | factionL_isInvisible (lua_State *L) |
| Checks to see if a faction is invisible the player. | |
| static int | factionL_isStatic (lua_State *L) |
| Checks to see if a faction has a static standing with the player. | |
| static int | factionL_reputationOverride (lua_State *L) |
| Gets the overriden reputation value of a faction. | |
| static int | factionL_setReputationOverride (lua_State *L) |
| Gets the overriden reputation value of a faction. | |
| static int | factionL_tags (lua_State *L) |
| Gets the tags a faction has. | |
| static int | factionL_dynAdd (lua_State *L) |
| Adds a faction dynamically. Note that if the faction already exists as a dynamic faction, the existing one is returned. | |
| static int | factionL_dynAlly (lua_State *L) |
| Adds or removes allies to a faction. Only works with dynamic factions. | |
| static int | factionL_dynEnemy (lua_State *L) |
| Adds or removes enemies to a faction. Only works with dynamic factions. | |
| static int | factionL_modplayer (lua_State *L) |
| Modifies the player's standing with the faction. | |
| static int | factionL_modplayersingle (lua_State *L) |
| Modifies the player's standing with the faction. | |
| static int | factionL_modplayerraw (lua_State *L) |
| Modifies the player's standing with the faction. | |
| static int | factionL_setplayerstanding (lua_State *L) |
| Sets the player's standing with the faction. | |
| static int | factionL_playerstanding (lua_State *L) |
| Gets the player's standing with the faction. | |
| static int | factionL_playerstandingdefault (lua_State *L) |
| Gets the player's default standing with the faction. | |
| int | nlua_loadFaction (nlua_env env) |
| Loads the faction library. | |
| LuaFaction | lua_tofaction (lua_State *L, int ind) |
| Gets faction at index. | |
| LuaFaction | lua_checkfaction (lua_State *L, int ind) |
| LuaFaction | luaL_validfaction (lua_State *L, int ind) |
| Gets faction (or faction name) at index, raising an error if type isn't a valid faction. | |
| LuaFaction * | lua_pushfaction (lua_State *L, LuaFaction faction) |
| Pushes a faction on the stack. | |
| int | lua_isfaction (lua_State *L, int ind) |
| Checks to see if ind is a faction. | |
Variables | |
| static const luaL_Reg | faction_methods [] |
Handles the Lua faction bindings.
These bindings control the factions.
Definition in file nlua_faction.c.
|
static |
Gets the allies of the faction.
Lua usage parameter: for k,v in pairs(f:allies()) do – Iterate over faction allies
Lua function parameter: Faction f Faction to get allies of. Lua return parameter: {Faction,...} A table containing the allies of the faction.
| L | Lua State |
Lua function: allies
Definition at line 749 of file nlua_faction.c.
|
static |
Enforces the local threshold of a faction starting at a particular system. Meant to be used when computing faction hits from the faction standing Lua scripts. Not meant for use elsewhere.
Lua function parameter: Faction f Faction to apply local thresholding to. Lua function parameter: System sys System to compute the thresholding from. This will be the reference and will not have its value modified.
| L | Lua State |
Lua function: applyLocalThreshold
Definition at line 575 of file nlua_faction.c.
|
static |
Checks to see if f is an ally of a.
Lua usage parameter: if f:areAllies( faction.get( "Pirate" ) ) then
Lua function parameter: Faction f Faction to check against. Lua function parameter: faction a Faction to check if is an enemy. Lua function parameter:[opt] System sys System to check to see if they are allies in. Mainly for when comparing to the player's faction. Lua return parameter: boolean true if they are enemies, false if they aren't.
| L | Lua State |
Lua function: areAllies
Definition at line 424 of file nlua_faction.c.
|
static |
Checks to see if f is an enemy of e.
Lua usage parameter: if f:areEnemies( faction.get( "Dvaered" ) ) then
Lua function parameter: Faction f Faction to check against. Lua function parameter: Faction e Faction to check if is an enemy. Lua function parameter:[opt] System sys System to check to see if they are enemies in. Mainly for when comparing to the player's faction. Lua return parameter: boolean true if they are enemies, false if they aren't.
| L | Lua State |
Lua function: areEnemies
Definition at line 401 of file nlua_faction.c.
|
static |
Checks to see if two factions are truly neutral with respect to each other.
Lua function parameter: Faction f Faction to check against. Lua function parameter: Faction n Faction to check if is true neutral. Lua return parameter: boolean true if they are truely neutral, false if they aren't.
| L | Lua State |
Lua function: areNeutral
Definition at line 381 of file nlua_faction.c.
|
static |
Gets the faction colour.
Lua function parameter: Faction f Faction to get colour from. Lua return parameter: Colour|nil The faction colour or nil if not applicable.
| L | Lua State |
Lua function: colour
Definition at line 804 of file nlua_faction.c.
|
static |
Adds a faction dynamically. Note that if the faction already exists as a dynamic faction, the existing one is returned.
Lua function parameter: Faction|nil base Faction to base it off of or nil for new faction. Lua function parameter: string name Name to give the faction. Lua function parameter:[opt] string display Display name to give the faction. Lua function parameter:[opt] table params Table of parameters. Options include "ai" (string) to set the AI to use, "clear_allies" (boolean) to clear all allies, "clear_enemies" (boolean) to clear all enemies, "player" (number) to set the default player standing, "colour" (string|colour) which represents the factional colours.
| L | Lua State |
Lua function: dynAdd
Definition at line 951 of file nlua_faction.c.
|
static |
Adds or removes allies to a faction. Only works with dynamic factions.
Lua function parameter: Faction fac Faction to add ally to. Lua function parameter: Faction ally Faction to add as an ally. Lua function parameter:[opt=false] boolean remove Whether or not to remove the ally from the faction instead of adding it.
| L | Lua State |
Lua function: dynAlly
Definition at line 1040 of file nlua_faction.c.
|
static |
Adds or removes enemies to a faction. Only works with dynamic factions.
Lua function parameter: Faction fac Faction to add enemy to. Lua function parameter: Faction enemy Faction to add as an enemy. Lua function parameter:[opt=false] boolean remove Whether or not to remove the enemy from the faction instead of adding it.
| L | Lua State |
Lua function: dynEnemy
Definition at line 1066 of file nlua_faction.c.
|
static |
Gets the enemies of the faction.
Lua usage parameter: for k,v in pairs(f:enemies()) do – Iterates over enemies
Lua function parameter: Faction f Faction to get enemies of. Lua return parameter: {Faction,...} A table containing the enemies of the faction.
| L | Lua State |
Lua function: enemies
Definition at line 724 of file nlua_faction.c.
|
static |
__eq (equality) metamethod for factions.
You can use the '==' operator within Lua to compare factions with this.
Lua usage parameter: if f == faction.get( "Dvaered" ) then
Lua function parameter: Faction f Faction comparing. Lua function parameter: Faction comp faction to compare against. Lua return parameter: boolean true if both factions are the same.
| L | Lua State |
Lua function: __eq
Definition at line 302 of file nlua_faction.c.
|
static |
Lua bindings to deal with factions.
Use like:
Lua module: faction
Gets a faction if it exists.
Lua usage parameter: f = faction.exists( "Empire" )
Lua function parameter: string name Name of the faction to get if exists. Lua return parameter: Faction The faction matching name or nil if not matched.
| L | Lua State |
Lua function: exists
Definition at line 147 of file nlua_faction.c.
|
static |
Gets the faction based on its name.
Lua usage parameter: f = faction.get( "Empire" )
Lua function parameter: string name Name of the faction to get. Lua return parameter: Faction The faction matching name.
| L | Lua State |
Lua function: get
Definition at line 166 of file nlua_faction.c.
|
static |
Gets all the factions.
Lua return parameter: {Faction,...} An ordered table containing all of the factions.
| L | Lua State |
Lua function: getAll
Definition at line 179 of file nlua_faction.c.
|
static |
Modifies the player's standing with the faction.
Also can modify the standing with allies and enemies of the faction.
Lua usage parameter: f:hit( -5, system.cur() ) – Lowers faction by 5 at the current system Lua usage parameter: f:hit( 10 ) – Globally increases faction by 10 Lua usage parameter: f:hit( 10, nil, nil, true ) – Globally increases faction by 10, but doesn't affect allies nor enemies of the faction.
Lua function parameter: Faction f Faction to modify player's standing with. Lua function parameter: number mod Amount of reputation to change. Lua function parameter: System|nil Whether to make the faction hit local at a system, or global affecting all systems of the faction. Lua function parameter:[opt="script"] string reason Reason behind it. This is passed as a string to the faction "hit" function. The engine can generate "kill" and "distress" sources. For missions the default is "script". Lua function parameter:[opt=false] boolean single Whether or not the hit should affect allies/enemies of the faction getting a hit. Lua return parameter: How much the reputation was actually changed after Lua script was run.
| L | Lua State |
Lua function: hit
Definition at line 458 of file nlua_faction.c.
|
static |
Simulates modifying the player's standing with a faction and computes how much would be changed.
Lua function parameter: Faction f Faction to simulate player's standing with. Lua function parameter: number mod Amount of reputation to simulate change. Lua function parameter: System|nil Whether to make the faction hit local at a system, or global. Lua function parameter:[opt="script"] string reason Reason behind it. This is passed as a string to the faction "hit" function. The engine can generate "kill" and "distress" sources. For missions the default is "script". Lua return parameter: How much the reputation was actually changed after Lua script was run.
| L | Lua State |
Lua function: hit
Definition at line 485 of file nlua_faction.c.
|
static |
Checks to see if a faction is invisible the player.
Lua usage parameter: b = f:invisible()
Lua function parameter: Faction f Faction to check if is invisible to the player. Lua return parameter: boolean true if the faction is invisible to the player.
| L | Lua State |
Lua function: invisible
Definition at line 855 of file nlua_faction.c.
|
static |
Checks to see if a faction is known by the player.
Lua usage parameter: b = f:known()
Lua function parameter: Faction f Faction to check if the player knows. Lua return parameter: boolean true if the player knows the faction.
| L | Lua State |
Lua function: known
Definition at line 823 of file nlua_faction.c.
|
static |
Checks to see if a faction has a static standing with the player.
Lua usage parameter: b = f:static()
Lua function parameter: Faction f Faction to check if has a static standing to the player. Lua return parameter: boolean true if the faction is static to the player.
| L | Lua State |
Lua function: static
Definition at line 872 of file nlua_faction.c.
|
static |
Gets the faction logo.
Lua function parameter: Faction f Faction to get logo from. Lua return parameter: Tex The faction logo or nil if not applicable.
| L | Lua State |
Lua function: logo
Definition at line 787 of file nlua_faction.c.
|
static |
Gets the faction's translated long name.
This translated name should be used for display purposes (e.g. messages) where the longer version of the faction's display name should be used. It cannot be used as an identifier for the faction; for that, use faction.nameRaw() instead.
Lua usage parameter: longname = f:longname() Lua function parameter: Faction f Faction to get long name of. Lua return parameter: string The long name of the faction (translated).
| L | Lua State |
Lua function: longname
Definition at line 365 of file nlua_faction.c.
|
static |
Modifies the player's standing with the faction.
Also modifies standing with allies and enemies of the faction.
Lua usage parameter: f:modPlayer( -5 ) – Lowers faction by 5
Lua function parameter: Faction f Faction to modify player's standing with. Lua function parameter: number mod The modifier to modify faction by. Lua function parameter:[opt="script"] string reason Reason behind it. This is passed as a string to the faction "hit" function. The engine can generate "kill" and "distress" sources. For missions the default is "script".
| L | Lua State |
Lua function: modPlayer
Definition at line 597 of file nlua_faction.c.
|
static |
Modifies the player's standing with the faction.
Does not affect other faction standings and is not processed by the faction Lua script, so it indicates exactly the amount to be changed.
Lua usage parameter: f:modPlayerRaw( 10 )
Lua function parameter: Faction f Faction to modify player's standing with. Lua function parameter: number mod The modifier to modify faction by.
| L | Lua State |
Lua function: modPlayerRaw
Definition at line 643 of file nlua_faction.c.
|
static |
Modifies the player's standing with the faction.
Does not affect other faction standings.
Lua usage parameter: f:modPlayerSingle( 10 )
Lua function parameter: Faction f Faction to modify player's standing with. Lua function parameter: number mod The modifier to modify faction by. Lua function parameter:[opt="script"] string reason Reason behind it. This is passed as a string to the faction "hit" function. The engine can generate "kill" and "distress" sources. For missions the default is "script".
| L | Lua State |
Lua function: modPlayerSingle
Definition at line 621 of file nlua_faction.c.
|
static |
Gets the faction's translated short name.
This translated name should be used for display purposes (e.g. messages) where the shorter version of the faction's display name should be used. It cannot be used as an identifier for the faction; for that, use faction.nameRaw() instead.
Lua usage parameter: shortname = f:name()
Lua function parameter: Faction f The faction to get the name of. Lua return parameter: string The name of the faction.
| L | Lua State |
Lua function: name
Definition at line 324 of file nlua_faction.c.
|
static |
Gets the faction's raw / "real" (untranslated, internal) name.
This untranslated name should be used for identification purposes (e.g. can be passed to faction.get()). It should not be used for display purposes; for that, use faction.name() or faction.longname() instead.
Lua usage parameter: name = f:nameRaw()
Lua function parameter: Faction f The faction to get the name of. Lua return parameter: string The name of the faction.
| L | Lua State |
Lua function: nameRaw
Definition at line 345 of file nlua_faction.c.
|
static |
Gets the player's faction.
Lua usage parameter: pf = faction.player()
Lua return parameter: Faction The player's faction.
| L | Lua State |
Lua function: player
Definition at line 199 of file nlua_faction.c.
|
static |
Gets the player's standing with the faction.
Lua usage parameter: if f:playerStanding() > 70 then – Player is an ally Lua usage parameter: _v, str = f:playerStanding(50) – Get the standing text for a value of 50
Lua function parameter: Faction f Faction to get player's standing with. Lua function parameter: number value Faction standing value to get string of. Lua return parameter: number The value of the standing and the human readable string. Lua return parameter: string The text corresponding to the standing (translated).
| L | Lua State |
Lua function: playerStanding
Definition at line 685 of file nlua_faction.c.
|
static |
Gets the player's default standing with the faction.
Lua function parameter: Faction f Faction to get player's default standing with. Lua return parameter: number The value of the standing.
| L | Lua State |
Lua function: playerStandingDefault
Definition at line 706 of file nlua_faction.c.
|
static |
Gets the player's default reputation with the faction.
Lua function parameter: Faction f Faction to get player's default standing with. Lua return parameter: number The value of the standing.
| L | Lua State |
Lua function: reputationDefault
Definition at line 541 of file nlua_faction.c.
|
static |
Gets the player's global reputation with the faction.
Lua usage parameter: if f:reputationGlobal() >= 0 then – Player is not hostile
Lua function parameter: Faction f Faction to get player's standing with. Lua return parameter: number The value of the standing.
| L | Lua State |
Lua function: reputationGlobal
Definition at line 506 of file nlua_faction.c.
|
static |
Gets the overriden reputation value of a faction.
Lua function parameter: Faction f Faction to get whether or not the reputation is overriden and the value. Lua return parameter: number|nil The override reputation value or nil if not overriden.
| L | Lua State |
Lua function: reputationOverride
Definition at line 888 of file nlua_faction.c.
|
static |
Gets the human readable standing text correpsonding (translated).
Lua function parameter: faction f Faction to get standing text from. Lua function parameter:[opt=f:reputationGlobal()] number|nil val Value to get the standing text of, or nil to use the global faction standing. Lua return parameter: string Translated text corresponding to the faction value.
| L | Lua State |
Lua function: reputationText
Definition at line 522 of file nlua_faction.c.
|
static |
Sets a faction's known state.
Lua usage parameter: f:setKnown( false ) – Makes faction unknown. Lua function parameter: Faction f Faction to set known. Lua function parameter:[opt=false] boolean b Whether or not to set as known.
| L | Lua State |
Lua function: setKnown
Definition at line 838 of file nlua_faction.c.
|
static |
Sets the player's standing with the faction.
Lua usage parameter: f:setPlayerStanding(70) – Make player an ally
Lua function parameter: Faction f Faction to set the player's standing for. Lua function parameter: number value Value to set the player's standing to (from -100 to 100).
| L | Lua State |
Lua function: setPlayerStanding
Definition at line 662 of file nlua_faction.c.
|
static |
Overrides the player's faction global standing with a faction. Use sparingly as it overrites local standings at all systems.
Lua function parameter: Faction f Faction to set the player's global reputation with. Lua function parameter: number The value of the reputation to set to.
| L | Lua State |
Lua function: setReputationGlobal
Definition at line 556 of file nlua_faction.c.
|
static |
Gets the overriden reputation value of a faction.
Lua function parameter: Faction f Faction to enable/disable reputation override of. Lua function parameter: number|nil Sets the faction reputation override to the value if a number, or disables it if nil.
| L | Lua State |
Lua function: setReputationOverride
Definition at line 907 of file nlua_faction.c.
|
static |
Gets the tags a faction has.
Lua usage parameter: for k,v in ipairs(f:tags()) do ... end Lua usage parameter: if f:tags().likes_cheese then ... end Lua usage parameter: if f:tags("generic") then ... end
Lua function parameter:[opt=nil] string tag Tag to check if exists. Lua return parameter: table|boolean Table of tags where the name is the key and true is the value or a boolean value if a string is passed as the second parameter indicating whether or not the specified tag exists.
| L | Lua State |
Lua function: tags
Definition at line 928 of file nlua_faction.c.
|
static |
Gets whether or not a faction uses hidden jumps.
Lua function parameter: Faction f Faction to get whether or not they use hidden jumps. Lua return parameter: boolean true if the faction uses hidden jumps, false otherwise.
| L | Lua State |
Lua function: usesHiddenJumps
Definition at line 773 of file nlua_faction.c.
| LuaFaction lua_checkfaction | ( | lua_State * | L, |
| int | ind ) |
Definition at line 217 of file nlua_faction.c.
| int lua_isfaction | ( | lua_State * | L, |
| int | ind ) |
Checks to see if ind is a faction.
| L | Lua state to check. |
| ind | Index position to check. |
Definition at line 274 of file nlua_faction.c.
| LuaFaction * lua_pushfaction | ( | lua_State * | L, |
| LuaFaction | faction ) |
Pushes a faction on the stack.
| L | Lua state to push faction into. |
| faction | Faction to push. |
Definition at line 259 of file nlua_faction.c.
| LuaFaction lua_tofaction | ( | lua_State * | L, |
| int | ind ) |
Gets faction at index.
| L | Lua state to get faction from. |
| ind | Index position to find the faction. |
Definition at line 212 of file nlua_faction.c.
| LuaFaction luaL_validfaction | ( | lua_State * | L, |
| int | ind ) |
Gets faction (or faction name) at index, raising an error if type isn't a valid faction.
| L | Lua state to get faction from. |
| ind | Index position to find the faction. |
Definition at line 243 of file nlua_faction.c.
|
static |
Definition at line 225 of file nlua_faction.c.
| int nlua_loadFaction | ( | nlua_env | env | ) |
Loads the faction library.
| env | Environment to load faction library into. |
Definition at line 119 of file nlua_faction.c.
|
static |
Faction metatable methods.
Definition at line 70 of file nlua_faction.c.