# Avorion Script API Documentation

Home Functions Search
Search:

onAllianceChanged
onAllianceInvitationReceived
onChatRestrictionTimeChanged
onConfirmSectorArrival
onGalaxyMapUpdate
onGroupChanged
onGroupLeaderChanged
onGroupPlayerCraftChanged
onGroupPlayerSectorChanged
onHideGalaxyMap
onHomeSectorChanged
onHyperspaceRestrictionTimeChanged
onItemAdded
onItemChanged
onItemPropertiesChanged
onItemRemoved
onKnownSectorAdded
onKnownSectorRemoved
onKnownSectorUpdated
onMailAdded
onMailCleared
onMailRead
onMailRemoved
onMailUpdated
onMapRenderAfterLayers
onMapRenderAfterTooltips
onMapRenderAfterUI
onMapRenderBeforeLayers
onNameChanged
onPlayerEnteredGroup
onPlayerLeftGroup
onPostRenderHud
onPostRenderIndicators
onPreRenderHud
onReconstructionSectorChanged
onRelationChanged
onRelationLevelChanged
onRelationStatusChanged
onResourcesChanged
onSectorChanged
onSelectMapCoordinates
onShipAvailabilityUpdated
onShipCargoUpdated
onShipChanged
onShipCrewUpdated
onShipHyperspacePropertiesUpdated
onShipIconUpdated
onShipInfoAdded
onShipInfoRemoved
onShipInfoUpdated
onShipNameUpdated
onShipOrderInfoUpdated
onShipPayDayUpdated
onShipPlanUpdated
onShipPositionUpdated
onShipReconstructionValueUpdated
onShipStatusMessageUpdated
onShipTitleUpdated
onShipTypeUpdated
onShowGalaxyMap
onStartDialog
onStateChanged
onStateFormChanged
onTraitChanged

# Player [Client] Callbacks

Note: Callbacks have to be buffered in certain situations and won't happen immediately. When unregistering a callback during a callback, all callbacks that were buffered during the last frame may still be sent, even though they were unregistered.

callback onAllianceChanged(allianceIndex)

Executed whenever the player's alliance changes

Parameters

allianceIndex The faction index of the alliance

callback onAllianceInvitationReceived(allianceIndex)

Executed whenever the player receives an invitation from an alliance

Parameters

allianceIndex The faction index of the alliance

callback onChatRestrictionTimeChanged(time)

Executed whenever a player's chat restriction time is changed. This usually only happens when administrators need to stop a player from using chat.

Parameters

time The time that player is muted

callback onConfirmSectorArrival(x, y)

Called whenever a loading screen is no longer visible and the player now sees the new sector

Parameters

x X coordinate of the new sector
y Y coordinate of the new sector

callback onGalaxyMapUpdate(timeStep)

Executed whenever the map is visible and updated by a game tick.

Parameters

timeStep The time step since the last update

callback onGroupChanged(groupIndex)

Executed whenever the player's group index changes

Parameters

groupIndex The index of the group the player is in

callback onGroupLeaderChanged(playerIndex)

Executed whenever the leader of the player's group changes

Parameters

playerIndex The index of the new leader player

callback onGroupPlayerCraftChanged(playerIndex, id)

Executed whenever another player of the player's group changes crafts

Parameters

playerIndex The index of the other player
id The id of the new craft

callback onGroupPlayerSectorChanged(playerIndex, x, y)

Executed whenever another player of the player's group changes sectors

Parameters

playerIndex The index of the other player
x The x coordinate of the new sector
y The y coordinate of the new sector

callback onHideGalaxyMap()

Executed whenever the player closes the map.

callback onHomeSectorChanged(x, y)

Called whenever the home sector of the player changes

Parameters

x The x coordinate of the new home sector
y The y coordinate of the new home sector

callback onHyperspaceRestrictionTimeChanged(time)

Executed whenever a player's hyperspace restriction time is changed. This usually only happens when administrators need to trap a player in a specific sector.

Parameters

time The time that player is trapped

callback onItemAdded(item, index, amount, amountBefore, tagsChanged)

Called whenever an item in the player inventory is added

Parameters

item The inventory item
index Index of the inventory item
amount Amount of items in the slot
amountBefore Amount of items in the slot before the change
tagsChanged Boolean indicating if the tags of the item changed

callback onItemChanged(item, index, amount, amountBefore)

Called whenever an item in the player inventory changes

Parameters

item The inventory item
index Index of the inventory item
amount Amount of items in the slot
amountBefore Amount of items in the slot before the change

callback onItemPropertiesChanged(item, index, amount)

Called whenever an item in the player inventory changes properties

Parameters

item The inventory item
index Index of the inventory item
amount Amount of items in the slot

callback onItemRemoved(item, index, amount, amountBefore)

Called whenever an item in the player inventory is removed

Parameters

item The inventory item
index Index of the inventory item
amount Amount of items in the slot
amountBefore Amount of items in the slot before the change

callback onKnownSectorAdded(x, y)

Called whenever a new tracked sector is added to the player database

Parameters

x The x coordinate of the sector
y The y coordinate of the sector

callback onKnownSectorRemoved(x, y)

Called whenever a tracked sector was removed from the player database

Parameters

x The x coordinate of the sector
y The y coordinate of the sector

callback onKnownSectorUpdated(x, y)

Called whenever a tracked sector is updated in the player database

Parameters

x The x coordinate of the sector
y The y coordinate of the sector

callback onMailAdded(mail, id)

Executed whenever the player receives a mail

Parameters

mail The mail the player received

callback onMailCleared(mailIndex, id)

Executed whenever a mail was cleared

Parameters

mailIndex The index of the cleared mail

callback onMailRead(mailIndex, id)

Executed whenever a mail was read

Parameters

mailIndex The index of the read mail

callback onMailRemoved(mailIndex, id)

Executed whenever a mail was removed from the player's mailbox

Parameters

mailIndex The index of the removed mail

callback onMailUpdated(mail, mailIndex)

Executed whenever a mail was updated

Parameters

mail The mail
mailIndex The index of the read mail

callback onMapRenderAfterLayers()

Executed whenever the map is rendered, after its layers were rendered

callback onMapRenderAfterTooltips()

Executed whenever the map is rendered, after its tooltips were rendered

callback onMapRenderAfterUI()

Executed whenever the map is rendered, after its UI was rendered

callback onMapRenderBeforeLayers()

Executed whenever the map is rendered, before its layers are rendered

callback onNameChanged(newName)

Called whenever the name of the player changes

Parameters

newName The new name of the player

callback onPlayerEnteredGroup(playerIndex)

Executed whenever another player enters the player's group

Parameters

playerIndex The index of the player who entered

callback onPlayerLeftGroup(playerIndex)

Executed whenever another player from the player's group leaves the group

Parameters

playerIndex The index of the player who left

callback onPostRenderHud(state)

Executed every frame during rendering after rendering the HUD. All render calls that should overlay the HUD should be done here.

Parameters

state The PlayerStateType of the client player (ie. flying, building, etc.)

callback onPostRenderIndicators(state)

Executed every frame during rendering after rendering the targeters. All render calls that draw target indicators should be done here.

Parameters

state The PlayerStateType of the client player (ie. flying, building, etc.)

callback onPreRenderHud(state)

Executed every frame during rendering before rendering the HUD. All render calls that are not supposed to overlay the HUD should be done here.

Parameters

state The PlayerStateType of the client player (ie. flying, building, etc.)

callback onReconstructionSectorChanged(x, y)

Executed whenever the player's respawn sector changes

Parameters

x The x coordinate of the new sector
y The y coordinate of the new sector

callback onRelationChanged(index, level, levelBefore, notify)

Called whenever relations of the player to another faction change

Parameters

index The index of the other faction
level The level of the relation
levelBefore The level of the relation before the change
notify A boolean indicating whether or not the player should be notified about the change

callback onRelationLevelChanged(index, level, levelBefore, notify)

Called whenever relation levels of the player to another faction change

Parameters

index The index of the other faction
level The level of the relation
levelBefore The level of the relation before the change
notify A boolean indicating whether or not the player should be notified about the change

callback onRelationStatusChanged(index, status, statusBefore, notify)

Called whenever the relation status of the player to another faction change (relation status is not yet implemented so this callback will most likely not fire until relation status is in)

Parameters

index The index of the other faction
status The status of the relations
statusBefore The status of the relation before the change
notify A boolean indicating whether or not the player should be notified about the change

callback onResourcesChanged(money, resources, infinite, notify)

Called whenever the amount of money or resources of the player changes

Parameters

money The amount of money the player owns
resources The amount of resources the player owns, as table
infinite True if the player has infinite resources, false otherwise
notify A boolean indicating whether or not the player should be visually notified in some way that the resources changed

callback onSectorChanged(x, y)

Executed whenever the player changes the sector

Parameters

x The x coordinate of the new sector
y The y coordinate of the new sector

callback onSelectMapCoordinates(x, y)

Executed whenever a coordinate on the map is selected.

callback onShipAvailabilityUpdated(name, availability)

Called whenever a ShipInfo changes availability status (ie. goes into background simulation)

Parameters

name The name of the ship
availability The new availability status of the ship

callback onShipCargoUpdated(name)

Called whenever the cargo of a ShipInfo changes

Parameters

name The name of the ship

callback onShipChanged(playerIndex, craftId, previousId)

Executed whenever the player changes the ship they're currently flying

Parameters

playerIndex Index of the player
craftId The id of the new craft
previousId The id of the previous craft

callback onShipCrewUpdated(name)

Called whenever the crew of a ShipInfo changes

Parameters

name The name of the ship

callback onShipHyperspacePropertiesUpdated(name, reach, canPassRifts)

Called whenever the hyperspace reach of a ShipInfo changes

Parameters

name The name of the ship
reach The new reach of the ship
canPassRifts A boolean indicating whether the ship can jump across rifts

callback onShipIconUpdated(name, icon)

Called whenever the icon of a ShipInfo changes

Parameters

name The name of the ship
icon The new icon of the ship

callback onShipInfoAdded(name)

Called whenever a ShipInfo is added to the player

Parameters

name The name of the new ship

callback onShipInfoRemoved(name)

Called whenever a ShipInfo is removed from the player

Parameters

name The name of the ship

callback onShipInfoUpdated(name)

Called whenever a ShipInfo is updated in some way

Parameters

name The name of the ship

callback onShipNameUpdated(name, newName)

Called whenever the name of a ShipInfo changes

Parameters

name The name of the ship
newName The new name of the ship

callback onShipOrderInfoUpdated(name, orderInfo)

Called whenever the order info of a ShipInfo changes

Parameters

name The name of the ship
orderInfo The order info of the ship

callback onShipPayDayUpdated(name, time)

Called whenever the payday of a ShipInfo changes

Parameters

name The name of the ship
time The payday of the ship

callback onShipPlanUpdated(name)

Called whenever the plan of a ShipInfo changes

Parameters

name The name of the ship

callback onShipPositionUpdated(name, x, y)

Called whenever a ShipInfo changes sectors

Parameters

name The name of the ship
x The new x coordinate of the ship
y The new y coordinate of the ship

callback onShipReconstructionValueUpdated(name, value)

Called whenever the reconstruction value of a ShipInfo changes

Parameters

name The name of the ship
value The value of the ship

callback onShipStatusMessageUpdated(name, status, arguments)

Called whenever the status info of a ShipInfo changes

Parameters

name The name of the ship
status The status info text of the ship
arguments A table holding the arguments of the status

callback onShipTitleUpdated(name)

Called whenever the title of a ShipInfo changes

Parameters

name The name of the ship

callback onShipTypeUpdated(name, type)

Called whenever the entity type of a ShipInfo changes

Parameters

name The name of the ship
type The new entity type of the ship

callback onShowGalaxyMap()

Executed whenever the player opens the map.

callback onStartDialog(objectIndex)

Executed when a dialog is started.

Parameters

objectIndex The index of the entity the dialog is started with

callback onStateChanged(newState, oldState)

Executed when the state of the player changes

Parameters

newState The new state of the player
oldState The old state of the player

callback onStateFormChanged(newForm)

Called whenever the state form of the player changes

Parameters

newForm The new state form of the player

callback onTraitChanged(trait, value)

Called whenever a "personality" trait of the player changes

Parameters

trait The name of the trait that was changed
value The value of the new trait, from -1 to 1
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