Home

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

get (name) Gets the faction based on its name.
__eq (f, comp) __eq (equality) metamethod for factions.
name (f) Gets the faction's name.
longname (f) Gets the faction's 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.
enemies (f) Gets the enemies of the faction.
allies (f) Gets the allies of the faction.
logoSmall (f) Gets the small faction logo which is 64x64 or smaller.
logoTiny (f) Gets the tiny faction logo which is 24x24 or smaller.
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.


Functions

get (name)
Gets the faction based on its name. ( 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. ( f, comp )

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 name. ( f )

Parameters:

  • f Faction The faction to get the name of.

Returns:

    string The name of the faction.

Usage:

    name = f:name()
longname (f)
Gets the faction's long name. ( f )

Parameters:

  • f Faction Faction to get long name of.

Returns:

    string The long name of the faction.

Usage:

    longname = f:longname()
areEnemies (f, e)
Checks to see if f is an enemy of e. ( f, 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. ( f, 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. ( f, mod )

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. ( f, mod )

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. ( f, mod )

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. ( f, value )

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. ( f )

Parameters:

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

Returns:

    number The value of the standing and the human readable string.

Usage:

    if f:playerStanding() > 70 then -- Player is an ally
enemies (f)
Gets the enemies of the faction. ( f )

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. ( f )

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
logoSmall (f)
Gets the small faction logo which is 64x64 or smaller. ( f )

Parameters:

  • f Faction Faction to get logo from.

Returns:

    Tex The small faction logo or nil if not applicable.
logoTiny (f)
Gets the tiny faction logo which is 24x24 or smaller. ( f )

Parameters:

  • f Faction Faction to get logo from.

Returns:

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

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. ( f )

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. ( f, b )

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.
generated by LDoc 1.4.3 Last updated 2020-03-30 00:45:13