Naev

Module faction

Lua bindings to deal with factions.

Use like:

 f = faction.get( "Empire" )
 if f:playerStanding() < 0 then
    -- player is hostile to "Empire"
 end
 

Functions

exists (name) Gets a faction if it exists.
get (name) Gets the faction based on its name.
__eq (f, comp) __eq (equality) metamethod for factions.
name (f) Gets the faction's translated short name.
nameRaw (f) Gets the faction's raw / "real" (untranslated, internal) name.
longname (f) Gets the faction's translated long name.
areEnemies (f, e) Checks to see if f is an enemy of e.
areAllies (f, a) Checks to see if f is an ally of a.
modPlayer (f, mod) Modifies the player's standing with the faction.
modPlayerSingle (f, mod) Modifies the player's standing with the faction.
modPlayerRaw (f, mod) Modifies the player's standing with the faction.
setPlayerStanding (f, value) Sets the player's standing with the faction.
playerStanding (f) Gets the player's standing with the faction.
playerStandingDefault (f) Gets the player's default standing with the faction.
enemies (f) Gets the enemies of the faction.
allies (f) Gets the allies of the faction.
usesHiddenJumps (f) Gets whether or not a faction uses hidden jumps.
logo (f) Gets the faction logo.
colour (f) Gets the faction colour.
known (f) Checks to see if a faction is known by the player.
setKnown (f[, b=false]) Sets a faction's known state.
tags (f) Gets the tags a faction has.
dynAdd (base, name[, display[, params]]) Adds a faction dynamically.
dynAlly (fac, ally[, remove=false]) Adds or removes allies to a faction.
dynEnemy (fac, enemy[, remove=false]) Adds or removes enemies to a faction.


Functions

exists (name)
Gets a faction if it exists.

Parameters:

  • name string Name of the faction to get if exists.

Returns:

    Faction The faction matching name or nil if not matched.

Usage:

    f = faction.exists( "Empire" )
    
get (name)
Gets the faction based on its name.

Parameters:

  • name string Name of the faction to get.

Returns:

    Faction The faction matching name.

Usage:

    f = faction.get( "Empire" )
    
__eq (f, comp)
__eq (equality) metamethod for factions.

You can use the '==' operator within Lua to compare factions with this.

Parameters:

  • f Faction Faction comparing.
  • comp Faction faction to compare against.

Returns:

    boolean true if both factions are the same.

Usage:

    if f == faction.get( "Dvaered" ) then
    
name (f)
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.

Parameters:

  • f Faction The faction to get the name of.

Returns:

    string The name of the faction.

Usage:

    shortname = f:name()
    
nameRaw (f)
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.

Parameters:

  • f Faction The faction to get the name of.

Returns:

    string The name of the faction.

Usage:

    name = f:nameRaw()
    
longname (f)
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.

Parameters:

  • f Faction Faction to get long name of.

Returns:

    string The long name of the faction (translated).

Usage:

    longname = f:longname()
    
areEnemies (f, e)
Checks to see if f is an enemy of e.

Parameters:

  • f Faction Faction to check against.
  • e Faction Faction to check if is an enemy.

Returns:

    string true if they are enemies, false if they aren't.

Usage:

    if f:areEnemies( faction.get( "Dvaered" ) ) then
    
areAllies (f, a)
Checks to see if f is an ally of a.

Parameters:

  • f Faction Faction to check against.
  • a faction Faction to check if is an enemy.

Returns:

    boolean true if they are enemies, false if they aren't.

Usage:

    if f:areAllies( faction.get( "Pirate" ) ) then
    
modPlayer (f, mod)
Modifies the player's standing with the faction.

Also modifies standing with allies and enemies of the faction.

Parameters:

  • f Faction Faction to modify player's standing with.
  • mod number The modifier to modify faction by.

Usage:

    f:modPlayer( -5 ) -- Lowers faction by 5
    
modPlayerSingle (f, mod)
Modifies the player's standing with the faction.

Does not affect other faction standings.

Parameters:

  • f Faction Faction to modify player's standing with.
  • mod number The modifier to modify faction by.

Usage:

    f:modPlayerSingle( 10 )
    
modPlayerRaw (f, mod)
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.

Parameters:

  • f Faction Faction to modify player's standing with.
  • mod number The modifier to modify faction by.

Usage:

    f:modPlayerRaw( 10 )
    
setPlayerStanding (f, value)
Sets the player's standing with the faction.

Parameters:

  • f Faction Faction to set the player's standing for.
  • value number Value to set the player's standing to (from -100 to 100).

Usage:

    f:setPlayerStanding(70) -- Make player an ally
    
playerStanding (f)
Gets the player's standing with the faction.

Parameters:

  • f Faction Faction to get player's standing with.

Returns:

  1. number The value of the standing and the human readable string.
  2. string The text corresponding to the standing (translated).

Usage:

    if f:playerStanding() > 70 then -- Player is an ally
    
playerStandingDefault (f)
Gets the player's default standing with the faction.

Parameters:

  • f Faction Faction to get player's default standing with.

Returns:

    number The value of the standing and the human readable string.
enemies (f)
Gets the enemies of the faction.

Parameters:

  • f Faction Faction to get enemies of.

Returns:

    {Faction,...} A table containing the enemies of the faction.

Usage:

    for k,v in pairs(f:enemies()) do -- Iterates over enemies
    
allies (f)
Gets the allies of the faction.

Parameters:

  • f Faction Faction to get allies of.

Returns:

    {Faction,...} A table containing the allies of the faction.

Usage:

    for k,v in pairs(f:allies()) do -- Iterate over faction allies
    
usesHiddenJumps (f)
Gets whether or not a faction uses hidden jumps.

Parameters:

  • f Faction Faction to get whether or not they use hidden jumps.

Returns:

    boolean true if the faction uses hidden jumps, false otherwise.
logo (f)
Gets the faction logo.

Parameters:

  • f Faction Faction to get logo from.

Returns:

    Tex The faction logo or nil if not applicable.
colour (f)
Gets the faction colour.

Parameters:

  • f Faction Faction to get colour from.

Returns:

    Colour or nil The faction colour or nil if not applicable.
known (f)
Checks to see if a faction is known by the player.

Parameters:

  • f Faction Faction to check if the player knows.

Returns:

    boolean true if the player knows the faction.

Usage:

    b = f:known()
    
setKnown (f[, b=false])
Sets a faction's known state.

Parameters:

  • f Faction Faction to set known.
  • b boolean Whether or not to set as known. (default false)

Usage:

    f:setKnown( false ) -- Makes faction unknown.
    
tags (f)
Gets the tags a faction has.

Parameters:

  • f Faction Faction to get tags of.

Returns:

    table A table containing all the tags of the faction.

Usage:

  • for k,v in ipairs(f:tags()) do ... end
    
  • if f:tags().likes_cheese then ... end
    
dynAdd (base, name[, display[, params]])
Adds a faction dynamically. Note that if the faction already exists as a dynamic faction, the existing one is returned.

Note Defaults to known.

Parameters:

  • base Faction or nil Faction to base it off of or nil for new faction.
  • name string Name to give the faction.
  • display string Display name to give the faction. (optional)
  • params table Table of parameters. Options include "ai" (string) to set the AI to use, "clear_allies" (boolean) to clear all allies, and "clear_enemies" (boolean) to clear all enemies. (optional)
dynAlly (fac, ally[, remove=false])
Adds or removes allies to a faction. Only works with dynamic factions.

Parameters:

  • fac Faction Faction to add ally to.
  • ally Faction Faction to add as an ally.
  • remove boolean Whether or not to remove the ally from the faction instead of adding it. (default false)
dynEnemy (fac, enemy[, remove=false])
Adds or removes enemies to a faction. Only works with dynamic factions.

Parameters:

  • fac Faction Faction to add enemy to.
  • enemy Faction Faction to add as an enemy.
  • remove boolean Whether or not to remove the enemy from the faction instead of adding it. (default false)
generated by LDoc 1.4.6 Last updated 2022-10-02 16:01:35