# Avorion Script API Documentation

Home Functions Search
Search:

Player [Client] Player
Properties
alliance
allianceIndex
cameraAt
cameraEye
cameraPosition
cameraUp
craft
craftFaction
craftId
craftIndex
fullLogId
group
index
infiniteResources
isAIFaction
isAlliance
isBehemothDLCInstalled
isBlackMarketDLCInstalled
isInteracting
isIntoTheRiftDLCInstalled
isPlayer
maxBuildableMaterial
maxBuildableSockets
maxNumMails
maxNumShips
maxNumStations
money
name
numMails
numShips
ownsBehemothDLC
ownsBlackMarketDLC
ownsIntoTheRiftDLC
selectedObject
state
Member Functions
addComparisonItem
buildingAllowed
callbacksRegistered
canPay
getAllRelations
getHomeSectorCoordinates
getInteractedEntity
getInventory
getKnownSector
getKnownSectorCoordinates
getKnownSectors
getKnownSectorsOfFaction
getKnownSectorsWithFaction
getMail
getNamesOfShipsInSector
getPlanStyle
getPlanStyleNames
getReconstructionSiteCoordinates
getRelation
getRelations
getRelationStatus
getResources
getScripts
getSelectionGroup
getSelectionGroups
getShipAvailability
getShipBoundingBox
getShipCanPassRifts
getShipCargo
getShipCargos
getShipDestroyed
getShipHyperspaceReach
getShipIcon
getShipNames
getShipOrderInfo
getShipPayment
getShipPaymentTime
getShipPlan
getShipPosition
getShipReconstructionValue
getShipStatus
getShipSystems
getShipTurretDesigns
getShipType
getValue
hasScript
invokeFunction
knowsFaction
knowsSector
ownsShip
registerCallback
sendCallback
sendChatMessage
setCameraKeyFrames
setFollowCamera
setSelectionGroup
startBuilding
startInteracting
stopInteracting
unregisterCallback

# Player [Client]

This object is only available on the client.

function Player()

Returns

A new instance of Player

property Alliance alliance | [read-only]

property var allianceIndex | [read-only]

property vec3 cameraAt | [read-only]

property vec3 cameraEye | [read-only]

property Matrix cameraPosition | [read-only]

property vec3 cameraUp | [read-only]

property Entity craft |

property UserObject craftFaction | [read-only]

property Uuid craftId |

property Uuid craftIndex |

property string fullLogId | [read-only]

property Group group | [read-only]

property int index | [read-only]

property bool infiniteResources |

property bool isAIFaction | [read-only]

property bool isAlliance | [read-only]

property bool isBehemothDLCInstalled | [read-only]

returns true if the Behemoth DLC is owned and installed according to local Steam

property bool isBlackMarketDLCInstalled | [read-only]

returns true if the Black Market DLC is owned and installed according to local Steam

property bool isInteracting | [read-only]

property bool isIntoTheRiftDLCInstalled | [read-only]

returns true if the Into The Rift DLC is owned and installed according to local Steam

property bool isPlayer | [read-only]

property Material maxBuildableMaterial |

property int maxBuildableSockets |

property unsigned int maxNumMails | [read-only]

property var maxNumShips | [read-only]

property var maxNumStations | [read-only]

property int money | [read-only]

property var name | [read-only]

property unsigned int numMails | [read-only]

property unsigned int numShips | [read-only]

property bool ownsBehemothDLC | [read-only]

returns true if the player owns the Behemoth DLC according to server

property bool ownsBlackMarketDLC | [read-only]

returns true if the player owns the Black Market DLC according to server

property bool ownsIntoTheRiftDLC | [read-only]

returns true if the player owns the Into The Rift DLC according to server

property Entity selectedObject |

property PlayerStateType state | [read-only]

function var addComparisonItem(var item)

Returns

nothing

function bool, string buildingAllowed(Entity entity)

function int callbacksRegistered(string callbackName, var functionName)

Check how many functions are registered to a callback from the current script VM.

Parameters

callbackName The name of the callback
functionName The name of the function for which to check. If nil, will count all functions that are registered to this callback.

Returns

The amount of functions registered to the callback

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

function Relation... getAllRelations()

function int, int getHomeSectorCoordinates()

function Entity getInteractedEntity()

function Inventory getInventory()

function SectorView getKnownSector(int x, int y)

function ivec2... getKnownSectorCoordinates()

function SectorView... getKnownSectors()

function SectorView... getKnownSectorsOfFaction(int factionIndex)

function SectorView... getKnownSectorsWithFaction(int factionIndex)

function Mail getMail(unsigned int index)

function string... getNamesOfShipsInSector(int x, int y)

function PlanStyle getPlanStyle(string name)

function string... getPlanStyleNames()

function int, int getReconstructionSiteCoordinates()

function Relation getRelation(int factionIndex)

function int getRelations(int factionIndex)

function int getRelationStatus(int factionIndex)

function unsigned int... getResources()

function table<int, string> getScripts()

function var getSelectionGroup(int index)

function var getSelectionGroups()

function var getShipAvailability(string name)

function Box getShipBoundingBox(string name)

function bool getShipCanPassRifts(string name)

function string getShipCargo(string name)

function table<TradingGood, int> getShipCargos(string name)

function var getShipDestroyed(string name)

function float getShipHyperspaceReach(string name)

function string getShipIcon(string name)

function string... getShipNames()

function var getShipOrderInfo(string name)

function float getShipPayment(string name)

function float getShipPaymentTime(string name)

function BlockPlan getShipPlan(string name)

function var... getShipPosition(string name)

function double getShipReconstructionValue(string name)

function string getShipStatus(string name)

function pair<class ScriptSystemUpgradeTemplate, bool>... getShipSystems(string name)

function table<int, TurretDesign> getShipTurretDesigns(string name)

function int getShipType(string name)

function var getValue(string name)

function bool hasScript(string name)

function var... invokeFunction(var scriptName, string functionName, var... arguments)

Invokes a function in a script of the player. Use this function to invoke functions from one script in another script. The first return value of the function is an integer indicating whether or not the call was successful. When it was, this integer is followed by the return values of the invoked function.

Parameters

scriptName The name of the script containing the function
functionName The name of the function that will be executed
arguments An arbitrary list of arguments that will be given to the invoked function. Only numbers, std::strings and nil are supported here.

Returns

Returns at least 1 value indicating if the call succeeded:
0 The call was successful. In this case, the return values of the script are returned in addition to the call result, following the call result.
3 The call failed because the given script was not found in the player.
4 The call failed because the given function was not found in the script.
5 The call failed because the script's state has errors and is invalid

function bool knowsFaction(int factionIndex)

function bool knowsSector(int x, int y)

function bool ownsShip(string name)

function var registerCallback(string callbackName, string functionName)

Register a callback in the player. The callback will be removed when the sector is changed or the receiver, if it's an entity, is destroyed. Double registration of callbacks doesn't work. When the same callback to the same callback of the same script instance is registered twice, it will still only be called once.

Parameters

callbackName The name of the callback
functionName The name of the function that will be executed in the script when the callback happens

Returns

nothing

function var sendCallback()

Returns

nothing

function var sendChatMessage(var content, var channel)

Returns

nothing

function var setCameraKeyFrames()

Returns

nothing

function var setFollowCamera(var entity)

Returns

nothing

function var setSelectionGroup(int index, var group_in)

Returns

nothing

function var startBuilding(Entity entity)

Returns

nothing

function var startInteracting(Entity entity, string scriptName, int optionIndex)

Returns

nothing

function var stopInteracting()

Returns

nothing

function var unregisterCallback(string callbackName, string functionName)

Returns

nothing

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