# Avorion Script API Documentation

Home Functions Search
Search:

Faction [Server] Faction
Properties
alwaysAtWar
baseName
fullLogId
homeSectorUnknown
index
infiniteResources
initialRelations
initialRelationsToPlayer
isAIFaction
isAlliance
isPlayer
money
name
stateForm
staticRelationsToAI
staticRelationsToAll
staticRelationsToPlayers
unformattedName
Member Functions
addPlanStyle
canPay
canPayMoney
canPayResource
clearValues
getAllRelations
getHomeSectorCoordinates
getInventory
getLanguage
getPlanStyle
getPlanStyleNames
getRelation
getRelations
getRelationStatus
getResources
getTrait
getTraits
getValue
getValues
hasStaticRelationsToFaction
knowsFaction
pay
payResource
payWithoutNotify
receive
receiveResource
receiveWithoutNotify
sendCallback
sendChatMessage
setHomeSectorCoordinates
setLanguage
setResources
setStaticRelationsToFaction
setTrait
setValue

# Faction [Server]

This object is only available on the server.

function Faction(var index)

Returns

A new instance of Faction

property bool alwaysAtWar |

property string baseName |

property string fullLogId | [read-only]

property bool homeSectorUnknown |

property int index | [read-only]

property bool infiniteResources |

property int initialRelations |

Note: AIFactions only

property int initialRelationsToPlayer |

Note: AIFactions only

property bool isAIFaction | [read-only]

property bool isAlliance | [read-only]

property bool isPlayer | [read-only]

property int money |

property string name | [read-only]

property string stateForm |

property bool staticRelationsToAI |

property bool staticRelationsToAll |

property bool staticRelationsToPlayers |

property Format unformattedName | [read-only]

function var addPlanStyle(string name, PlanStyle style)

Returns

nothing

function bool, string, table<int, string> canPay()

function bool, string, table<int, string> canPayMoney(int money)

function bool, string, table<int, string> canPayResource(Material material, int amount)

function var clearValues()

Removes all custom values of the object

Returns

nothing

function Relation... getAllRelations()

function int, int getHomeSectorCoordinates()

function Inventory getInventory()

function Language getLanguage()

function PlanStyle getPlanStyle(string name)

function string... getPlanStyleNames()

function Relation getRelation(int otherFactionIndex)

function int getRelations(int factionIndex)

function int getRelationStatus(int factionIndex)

function int... getResources()

function float getTrait(string trait)

Retrieves a trait value associated with a key

Parameters

trait The name of the trait

Returns

The trait value associated with the key

function table<string, float> getTraits()

Retrieves all key-value trait pairs of the faction

Returns

A table containing all custom key-value pairs

function var getValue(string key)

Retrieves a custom value saved in the entity with the given key

Parameters

key A string that serves as the name of the value

Returns

The value if the key exists, otherwise nil

function table<string, var> getValues()

Retrieves all key-value pairs of custom values

Returns

A table containing all custom key-value pairs

function bool hasStaticRelationsToFaction(int factionIndex)

function bool knowsFaction(int factionIndex)

function var pay(string or Format [optional] description, int money, int... resources)

Makes the faction pay a certain amount of money and resources. If the faction can't pay, the respective money and resources will be set to 0. This function accepts an optional string for Format as first argument, as an economy notification describing the transaction that will be sent to the player, in case the faction is a player.
To ease handling of transaction descriptions, the format description (if set) will receive all the remaining arguments given to the pay() function as format arguments, in the same order as they are given to the function. Dots for easier reading will be inserted as well. Examples:
faction:pay("Paid %1% Credits and %2% iron.", 50000, 250)
-> "Paid 50.000 Credits and 250 iron."
faction:pay(Format("%1% paid %2% Credits and %3% iron.", "Excelsior"), 50, 25000)
-> "Excelsior paid 50 Credits and 25.000 iron."

Parameters

description [optional] A description for the transaction. Can either be a string or a Format. If this variable is set, money and resources will be appended to the end of the list of arguments passed to the description format string.
money Money that will be removed from the faction
resources A list of resources, starting with iron, that will be removed from the faction

Returns

nothing

function var payResource(string or Format description, Material material, int amount)

Makes the faction pay a certain amount of resources. If the faction can't pay, the respective resource will be set to 0. This function accepts a string for Format as first argument, as an economy notification describing the transaction that will be sent to the player, in case the faction is a player.

Parameters

description A description for the transaction. Can either be a string or a Format.
material The kind of material that will be removed from the faction
amount Amount that will be removed from the faction

Returns

nothing

function var payWithoutNotify(string or Format description, int money, int... args)

Similar behavior to pay(), except there will not be a notification popping up in case the faction is a player, and the description for the transaction in this function isn't optional.

Parameters

description A description for the transaction. Can either be a string or a Format. Money and resources will be appended to the end of the list of arguments passed to the description format string.
money Money that will be removed from the faction
args A list of resources, starting with iron, that will be removed from the faction

Returns

nothing

function var receive(string or Format [optional] description, int money, int... resources)

Makes the faction receive a certain amount of money and resources. This function accepts an optional string for Format as first argument, as an economy notification describing the transaction that will be sent to the player, in case the faction is a player.
To ease handling of transaction descriptions, the format description (if set) will receive all the remaining arguments given to the receive() function as format arguments, in the same order as they are given to the function. Dots for easier reading will be inserted as well. Examples:
faction:receive("Got %1% Credits and %2% iron.", 50000, 250)
-> "Got 50.000 Credits and 250 iron."
faction:receive(Format("%1% received %2% Credits and %3% iron.", "Excelsior"), 50, 25000)
-> "Excelsior received 50 Credits and 25.000 iron."

Parameters

description [optional] A description for the transaction. Can either be a string or a Format. If this variable is set, money and resources will be appended to the end of the list of arguments passed to the description format string.
money Money that will be given to the faction
resources A list of resources, starting with iron, that will be given to the faction

Returns

nothing

function var receiveResource(string or Format description, Material material, int amount)

Makes the faction receive a certain amount of resources. This function accepts a string for Format as first argument, as an economy notification describing the transaction that will be sent to the player, in case the faction is a player.

Parameters

description A description for the transaction. Can either be a string or a Format.
material The kind of material that will be given to the faction
amount Amount that will be given to the faction

Returns

nothing

function var receiveWithoutNotify(string or Format description, int money, int... args)

Similar behavior to receive(), except there will not be a notification popping up in case the faction is a player, and the description for the transaction in this function isn't optional.

Parameters

description A description for the transaction. Can either be a string or a Format. Money and resources will be appended to the end of the list of arguments passed to the description format string.
money Money that will be given to the faction
args A list of resources, starting with iron, that will be given to the faction

Returns

nothing

function var sendCallback()

Returns

nothing

function var sendChatMessage()

Returns

nothing

function var setHomeSectorCoordinates(int x, int y)

Returns

nothing

function var setLanguage(Language language)

Returns

nothing

function var setResources()

Returns

nothing

function var setStaticRelationsToFaction(int factionIndex, bool in)

Returns

nothing

function var setTrait(string trait, float value)

Sets a trait value associated with a key

Parameters

trait The name of the trait
value The value of the trait, should be between -1 and 1

Returns

nothing

function var setValue(string key, var value)

Sets a custom value

Parameters

key A string that serves as the name of the value
value The value to save. Must be bool, number, string or nil. If nil is given, the value will be deleted.
Overview
Home Functions Search
Search:
Callbacks
Callbacks Alliance [Client] Callbacks Alliance [Server] Callbacks Alliance [Server] Callbacks Entity Callbacks Galaxy Callbacks Player Callbacks Player [Client] Callbacks Sector Callbacks Server Callbacks
Predefined Functions & Example Scripts
Command Entity FactionDatabase PlanGenerator Player Sector Server UsableInventoryItem
Common Components
Boarding BspTree CargoBay CargoLoot ControlUnit CrewComponent DeletionTimer DirectFlightPhysics DockingClamps DockingParent DockingPositions Durability EnergySystem Engine FighterAI Hangar HyperspaceEngine InteractionText InventoryItemLoot Owner Physics Plan ReadOnlyBoarding ReadOnlyBspTree ReadOnlyCargoBay ReadOnlyControlUnit ReadOnlyCrew ReadOnlyDeletionTimer ReadOnlyEnergySystem ReadOnlyEngine ReadOnlyFighterAI ReadOnlyHangar ReadOnlyHyperspaceEngine ReadOnlyInteractionText ReadOnlyOwner ReadOnlyPhysics ReadOnlyPlan ReadOnlyShipAI ReadOnlyShipSystem ReadOnlyTorpedoAI [Server] [Client] [Server] [Client] ReadOnlyTorpedoAI [Server] [Client] [Server] [Client] ReadOnlyTorpedoLauncher ReadOnlyTurretBases ReadOnlyVelocity ReadOnlyWeapons ReadOnlyWormHole Shield ShipAI ShipSystem StructuralIntegrity SystemUpgradeLoot Thrusters Torpedo TorpedoAI TorpedoLauncher Turret TurretAI TurretBases Velocity Weapons WormHole
Common Objects
AllianceMember AllianceRank BlockPlan BlockPlanBlock BlockStatistics Box Captain Color ControlUnitSeat CraftDesign CraftStatsOverview Crew CrewMan CrewProfession DebugInfo dvec2 dvec3 dvec4 Entity EntityDescriptor FighterTemplate Format GameSettings Group HighResolutionTimer Inventory InventoryTurret ivec2 ivec3 ivec4 Language Mail Material Matrix ModManager NamedFormat PlanBspTree PlanetSpecifics PlanGenerationStage PlanPart PlanStyle PlayerId PluralForm Profiler QuadTree Random Rarity Ray ReadOnlyEntity Rect Relation Scenario SectorView Seed Sphere Squad SystemUpgradeTemplate Timer Tooltip TooltipLine TorpedoShaft TorpedoTemplate TradingGood TurretDesign TurretDesignPart TurretTemplate UsableInventoryItem Uuid VanillaInventoryItem vec2 vec3 vec4 Version Weapon
Client Components
EntityIcon EntityTooltip PlanMesh ReadOnlyIcon ReadOnlyPlanMesh ReadOnlyScriptUI ReadOnlyTooltip ScriptUI
Client Objects
Achievements Alliance [Client] CameraKeyFrame CaptainSelectionItem Client ClientSettings ColorSelectionItem CraftDesignSelectionItem Faction [Client] Galaxy [Client] GalaxyMap GameInput GlowFX IconSelectionItem InputWindow InventoryReferenceSelectionItem InventorySelectionItem Keyboard LaserFX Mouse Music PixelIconSelectionItem Planet Player [Client] PlayerWindow RefractionFX Sector [Client] SelectionItem ShipDatabaseEntry [Client] SoundSource StrategyState TargetIndicator TooltipRenderer TurretDesignSelectionItem
Client UI Objects
AllianceEmblem AllianceTab ArrowLine Button [Client] [Client] Button [Client] [Client] CaptainIcon CaptainProfile CheckBox ComboBox ContextMenu CraftPortrait CrewBar Frame Hud InventorySelection Label Line ListBox ListBoxEx MapArrowLine MapIcon MultiLineTextBox NumbersBar Picture PlanDisplayer ProgressBar SavedDesignsSelection ScrollFrame Selection ShipWindow Slider StatisticsBar Tab TabbedWindow TextBox TextField TooltipDisplayer Tree UIArbitraryHorizontalSplitter UIArbitraryVerticalSplitter UIContainer UIElement UIGridSplitter UIHorizontalLister UIHorizontalMultiSplitter UIHorizontalSplitter UIOrganizer UIRect UIRenderer UIVerticalLister UIVerticalMultiSplitter UIVerticalSplitter ValueComboBox Window
Server Components
EntityTransferrer FighterController Loot ReadOnlyEntityTransferrer ReadOnlyFighterController ReadOnlyLoot ReadOnlyTurretController ReadOnlyWreckageCreator TurretController WreckageCreator
Server Objects
Alliance [Server] Faction [Server] Galaxy [Server] Player [Server] ReadOnlySector Sector [Server] Server ShipDatabaseEntry [Server]
Enums
AIState AlliancePrivilege BeamShape BlockShading BlockStructure BlockType BlockType2 BoxType BuildError CaptainGenderId ChatChannel ChatMessageType ComponentType ControlAction ControlActionBit ControlStyle CoolingType CraftStatsOverviewStat CrewProfessionType CrewRank DamageSource DamageType DeletionType Difficulty EntityArrivalType EntityType FighterOrders FighterStartError FighterType FontType ImpactParticles InventoryItemType JumpError KeyboardKey ListBoxEntryType MalusReason MaterialType MoonType MouseButton PlanetType PlanTypeFilter PlayerStateType ProjectileShape RarityType RelationStatus SavedDesignType ScenarioType SectorChangeType ShipAvailability SoundType StatsBonuses TargetIndicatorVisuals TransformationFeature TurretAutoFireMode TurretSlotType WeaponAppearance WeaponCategory

This is the official documentation for the scripting API of Avorion. This documentation is automatically generated and not necessarily complete. Depending on the context in which functions exist, some documentation such as descriptions, return values or variable names or types may be missing.

Work in Progress. Documentation of Avorion Version: 2.5.8 a0d3f0b5b065