# Module `FACTION_SCRIPT_INTERFACE`

Extensions to the game's faction object.

## Functions

GetMemoryAddress () | Returns the memory address of the faction object as a hexadecimal string.
GetTreasury () | Gets the amount of gold (treasury) for the faction.
SetTreasury (value) | Sets the amount of gold (treasury) for the faction.
SetCapital (region) | Makes the given region the faction's capital.
InstantlyResearchTechnology (technology_key) | Instantly completes research of the given technology for the faction, using the game's own internal path for finishing a technology.
SetFactionLeader (new_character[, old_character[, heir_coming_of_age]]) | Sets a new leader for the faction.
GetPoliticalParties () | Returns a list interface for the faction's campaign political parties.
GetPoliticalParty (party_key) | Returns the faction's political party with the given record key, or nil.
GetPrimaryParty () | Returns the faction's primary (leading) political party, or nil.
HasPoliticalParties () | Returns whether the faction has any campaign political parties.

## Functions

GetMemoryAddress ()
  Returns the memory address of the faction object as a hexadecimal string.

  ### Returns:

  string memory address (e.g. "0x12345678")
GetTreasury ()
  Gets the amount of gold (treasury) for the faction.

  ### Returns:

  integer amount of gold
SetTreasury (value)
  Sets the amount of gold (treasury) for the faction.

  ### Parameters:

  - value integer new amount of gold
SetCapital (region)
  Makes the given region the faction's capital. Works even if the faction currently has no home region: the fields are set exactly as the engine does in FACTION::attachtoregion, including the original home region and home theatre when they are not yet assigned.

  ### Parameters:

  - region userdata the region to become the new capital
InstantlyResearchTechnology (technology_key)
  Instantly completes research of the given technology for the faction, using the game's own internal path for finishing a technology. This is exactly what the engine does when a tech completes, so events, achievements and unit upgrades fire normally, and parent prerequisites are completed automatically. Note: this differs from the game's built-in `cm:unlock_technology`, which only makes a technology selectable and never actually finishes the research.

  ### Parameters:

  - technology_key string the technology record key (e.g. "atttechmilitary_barracks")

  ### Returns:

  boolean true if the technology was found and completed
SetFactionLeader (new_character[, old_character[, heir_coming_of_age]])
  Sets a new leader for the faction. If `old_character` is provided, the game fires a succession event. If `heir_coming_of_age` is true, fires `faction_succession_heir_comes_of_age` instead of the default succession event.

  ### Parameters:

  - new_character userdata the character to become the new leader
  - old_character userdata the outgoing leader (triggers succession event if provided) (optional)
  - heir_coming_of_age boolean fire the heir-comes-of-age event variant (default false) (optional)
GetPoliticalParties ()
  Returns a list interface for the faction's campaign political parties. Use `num_items()` and zero-based `item_at(index)` to iterate it. Each party exposes GetKey(), GetSenators(), GetPower() and IsPrimary().

  ### Returns:

  userdata POLITICALPARTYLISTSCRIPTINTERFACE
GetPoliticalParty (party_key)
  Returns the faction's political party with the given record key, or nil.

  ### Parameters:

  - party_key string the party record key (e.g. "attpoliticalpartyromans1")

  ### Returns:

  userdata CAMPAIGNPOLITICALPARTY or nil
GetPrimaryParty ()
  Returns the faction's primary (leading) political party, or nil.

  ### Returns:

  userdata CAMPAIGNPOLITICALPARTY or nil
HasPoliticalParties ()
  Returns whether the faction has any campaign political parties.

  ### Returns:

  boolean true if the faction has at least one party

generated by LDoc 1.5.0