Avorion Script API Documentation
Sector 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 onAIStateChanged(entityId, state)
Executed whenever the AI state of an entity changes
Parameters
state The id of the new state
callback onAllScriptValuesChanged(entityId)
Executed whenever all scripts values of an entity in the sector have been changed at once
Parameters
callback onBlockChanged(objectIndex, blockIndex, changeFlags)
Executed whenever a plan of an entity is changed in the sector.
Parameters
blockIndex The index of the block
changeFlags The flags of the block changes
callback onBlockDamaged(objectIndex, blockIndex, inflictorId, damage, damageType)
Executed whenever a block object is damaged in the sector. This callback is executed after the damage is dealt to the block. Don't remove the block in this callback, this will lead to a crash.
Parameters
blockIndex The index of the damaged block
inflictorId The id of the entity that inflicted the damage
damage The damage that was inflicted to the entity
damageType The type of damage
callback onBlockDestroyed(objectIndex, index, block, lastDamageInflictor, damageSource)
Executed whenever a block of a block object got destroyed This callback is executed *after* the block was destroyed
Parameters
index Index of the block
block The block (as removed from the plan)
lastDamageInflictor The index of the last entity that inflicted damage to the destroyed block
damageSource The source of damage
callback onBlockHealed(objectIndex, blockIndex, damage)
Executed whenever a block of an object is healed in the sector. Don't remove the block in this callback, this will lead to a crash.
Parameters
blockIndex The index of the healed block
damage The damage the entity was healed for
callback onBlockPlanChanged(objectIndex, allBlocksChanged)
Executed whenever a plan of an entity is changed in the sector.
Parameters
allBlocksChanged A boolean that indicates whether all the blocks in the block plan have potentially changed
callback onBlocksAdded(objectIndex, wasRepaired, blockIndices)
Executed whenever new blocks are added to the entity. This callback is executed after the block was added.
Parameters
wasRepaired true if the callback was fired because of a repair operation, false otherwise
blockIndices The indices of the added blocks, as variable arguments list
callback onBlocksRemove(objectIndex, blockIndices)
Executed whenever a block will be removed from the plan by building (instead of combat). This callback is executed before the block is removed. IMPORTANT! This only fires on blocks that the player directly chose to be removed. Blocks that get removed because they don't have a connection to the root block any more get signalled after removal by 'onBlocksRemoved'.
Parameters
blockIndices The indices of the removed blocks, as variable arguments list
callback onBlocksRemoved(objectIndex, blockIndices)
Executed whenever a block is removed from the plan by building (instead of combat). This callback is executed after the block is removed.
Parameters
blockIndices The indices of the removed blocks, as variable arguments list
callback onBoardersDefeated(entityId, attackingFaction)
Executed whenever all boarders were defeated
Parameters
attackingFaction The index of the attacking faction
callback onBoardersLand(entityId, attackingFaction, firstLanding)
Executed when boarders land on an entity
Parameters
attackingFaction The index of the attacking faction
firstLanding True if these are the first boarders, false otherwise
callback onBoardingFight(entityId, attackingFaction)
Executed on every round of fighting with boarders
Parameters
attackingFaction The index of the attacking faction
callback onBoardingSuccessful(entityId, oldFactionIndex, newFactionIndex)
Executed whenever an entity was boarded successfully
Parameters
oldFactionIndex The index of the faction that owned the entity before boarding
newFactionIndex The index of the attacking faction that now owns the entity
callback onCargoChanged(objectIndex, delta, good)
Executed whenever the cargo of an entity in the sector changes. This callback is executed *after* the cargo was changed on the entity.
Parameters
delta The amount of cargo that changed
good The good that changed
callback onCargoLootCollected(collector, lootIndex, amount, good, owner)
Executed whenever trading good loot gets collected by a player
Parameters
lootIndex The index of the collected loot
amount The amount of goods that were collected
good The good that was inside the loot entity
owner The original owner of the cargo
callback onCollision(objectIndexA, objectIndexB, damageA, damageB, steererA, steererB)
Executed whenever two block objects collided in the sector
Parameters
objectIndexB The index of the other colliding object
damageA The damage that is inflicted to object A
damageB The damage that is inflicted to object B
steererA The steerer ID of objectA. When an object is docked, not the object itself but the steerer is the one responsible for collisions
steererB The steerer ID of objectB. When an object is docked, not the object itself but the steerer is the one responsible for collisions
callback onCraftSeatEntered(entityId, seat, playerIndex, firstPlayer)
Executed whenever a player enters a craft
Parameters
seat The seat index
playerIndex The index of the player that entered the seat
firstPlayer A bool indicating whether the craft's seats were empty before
callback onCraftSeatLeft(entityId, seat, playerIndex, playersRemaining)
Executed whenever a player leaves a craft
Parameters
seat The seat index that was previously occupied
playerIndex The index of the player that left the seat
playersRemaining A bool indicating whether there are still players on the craft
callback onCrewChanged(index)
Executed whenever the crew of a entity in the sector changes. This callback is executed *after* the crew was changed on the entity.
Parameters
callback onCrewChanged(index, delta, profession)
Executed whenever the crew of an entity in the sector changes. This callback is executed *after* the crew was changed on the entity.
Parameters
delta The amount of crewmen that changed
profession The profession of the crew that changed
callback onCrewLootCollected(collector, lootIndex)
Executed whenever trading good loot gets collected by a player
Parameters
lootIndex The index of the collected loot
callback onDamaged(objectIndex, amount, inflictor, damageSource, damageType)
Executed whenever an entity is damaged in the sector.
Parameters
amount The amount of damage that was dealt
inflictor The id of the entity that dealt the damage
damageSource The source of damage
damageType The type of damage
callback onDestroyed(index, lastDamageInflictor)
Executed whenever an entity with durability was destroyed in the sector
Parameters
lastDamageInflictor The index of the last entity that inflicted damage to the destroyed entity
callback onDockedByEntity(dockeeId, dockerId)
Executed whenever an entity was docked to another entity
Parameters
dockerId The id of the docking entity (parent)
callback onEntityCreated(entityId)
Executed whenever a new entity is created in the sector
Parameters
callback onEntityDocked(dockerId, dockeeId)
Executed whenever an entity docks to another entity
Parameters
dockeeId The id of the entity that was docked (child)
callback onEntityEntered(shipIndex)
Executed whenever a entity enters the sector.
Parameters
callback onEntityJump(shipId, x, y, sectorChangeType)
Executed whenever a entity jumps into another sector.
Parameters
x The x coordinate of the target sector
y The y coordinate of the target sector
sectorChangeType SectorChangeType enum what kind of sector change it is
callback onEntityRemoved(entityId)
Executed whenever an entity was removed from the sector
Parameters
callback onEntityUndocked(dockerId, dockeeId)
Executed whenever an entity undocks from another entity
Parameters
dockeeId The id of the entity that was docked (child)
callback onFighterAdded(entityId, squadIndex, fighterIndex, landed)
Executed whenever a fighter is added to an entity in the sector
Parameters
squadIndex The index of the squad
fighterIndex The index of the fighter in the squad
landed A boolean whether the fighter landed or got added otherwise
callback onFighterLanded(entityId, squadIndex, fighterId)
Executed whenever a fighter lands in a hangar in the sector
Parameters
squadIndex The index of the squad
fighterId The id of the fighter that landed
callback onFighterRemove(entityId, squadIndex, fighterIndex, started)
Executed whenever a fighter is removed from an entity in the sector, before it gets removed
Parameters
squadIndex The index of the squad
fighterIndex The index of the fighter in the squad
started A boolean whether the fighter started or got removed otherwise
callback onFighterRemoved(entityId, squadIndex, fighterIndex, started)
Executed whenever a fighter is removed from an entity in the sector, after it got removed
Parameters
squadIndex The index of the squad
fighterIndex The index of the fighter in the squad
started A boolean whether the fighter started or got removed otherwise
callback onFighterStarted(entityId, squadIndex, fighterId)
Executed whenever a fighter starts from a hangar in the sector
Parameters
squadIndex The index of the squad
fighterId The id of the fighter that started
callback onHealed(objectIndex, amount, inflictor)
Executed whenever an entity is healed in the sector.
Parameters
amount The amount of damage that was healed
inflictor The id of the entity that dealt the damage
callback onHullHit(objectIndex, blockIndex, shooterIndex, damage, location)
Executed whenever a block object is hit by a shot in the sector. Don't delete the block that is hit by the shot, this will lead to a crash.
Parameters
blockIndex The index of the block that was hit by the shot
shooterIndex The index of the craft that fired the shot
damage The damage the shot dealt to the object
location The impact location
callback onInventoryItemLootCollected(collector, lootIndex)
Executed whenever inventory item loot gets collected by an entity
Parameters
lootIndex The index of the loot that was collected
callback onLootCollected(collector, lootIndex)
Executed whenever loot gets collected by anyone, be it player or AI faction
Parameters
lootIndex The index of the collected loot
callback onMaterialLootCollected(collector, lootIndex, materialType, value)
Executed whenever material loot gets collected by an entity
Parameters
lootIndex The index of the loot that was collected
materialType The type of material contained in the loot
value The amount of material the loot contained
callback onMoneyLootCollected(collector, lootIndex, value)
Executed whenever money loot gets collected by an entity
Parameters
lootIndex The index of the collected loot
value The amount of credits the loot contained
callback onPlanModifiedByBuilding(shipIndex)
Executed whenever the plan of an entity was modified by building, meaning adding or removing blocks.
Parameters
callback onPlayerEntered(playerIndex, sectorChangeType)
Executed whenever a player enters the sector. This callback is executed immediately before the contents of the sector are sent to the player
Parameters
sectorChangeType The kind of sector change that is happening
callback onPlayerLeft(playerIndex, sectorChangeType)
Executed whenever a player leaves the sector. Executed after the player left.
Parameters
sectorChangeType The kind of sector change that is happening
callback onRestoredFromDisk(time)
Executed when a sector is loaded/restored from disk. This callback is called after the "restore" callback, for both entity and sector scripts.
Parameters
callback onScriptAdded(entityId, scriptIndex, scriptPath)
Executed after a script was added to an entity in the sector
Parameters
scriptIndex The index of the new script
scriptPath The path of the new script
callback onScriptRemoved(entityId, oldScriptIndex, scriptPath)
Executed after a script was removed from an entity in the sector
Parameters
oldScriptIndex The old index of the script that was removed
scriptPath The path of the old script
callback onScriptValueChanged(entityId, name, value)
Executed whenever a script value of an entity in the sector was changed
Parameters
name The name of the value
value The new value
callback onSectorGenerated(time)
Executed when a sector is generated/created for the first time for both entity and sector scripts.
Parameters
callback onSetForDeletion(entityId, deletionType)
Executed whenever an entity is to be deleted.
Parameters
deletionType The deletion type
callback onShieldActivate(entityId)
Executed whenever a shield activates in the sector
Parameters
callback onShieldDamaged(entityId, amount, damageType, inflictorId)
Executed whenever a shield is damaged in the sector
Parameters
amount The amount of damage inflicted
damageType The type of damage dealt
inflictorId The id of the entity that inflicted the damage
callback onShieldDeactivate(entityId)
Executed whenever a shield deactivates in the sector
Parameters
callback onShieldHealed(entityId, amount)
Executed whenever a shield is healed in the sector
Parameters
amount The amount of damage healed
callback onShieldHit(objectIndex, shooterIndex, damage, location)
Executed whenever an object's shield is hit by a shot in the sector.
Parameters
shooterIndex The index of the craft that fired the shot
damage The damage the shot dealt to the object
location The impact location
callback onShotCreated(shotIndex)
Executed whenever a new shot is created in the sector
Parameters
callback onShotFired(entityId)
Executed whenever a shot is fired in the sector
Parameters
callback onShotHit(objectIndex, shooterIndex, location)
Executed whenever a block object is hit by a shot in the sector.
Parameters
shooterIndex The index of the craft that fired the shot
location The impact location
callback onSquadAdded(entityId, index)
Executed whenever a squad is added to an entity in the sector
Parameters
index The index of the squad
callback onSquadOrdersChanged(entityId, squadIndex, orders, targetId)
Executed whenever the orders of a squad change in the sector
Parameters
squadIndex The index of the squad
orders The orders of the squad
targetId The target assigned to the fighters
callback onSquadRemove(entityId, index)
Executed whenever a squad is removed from an entity in the sector, before the squad gets removed
Parameters
index The index of the squad
callback onSquadRemoved(entityId, index)
Executed whenever a squad is removed from an entity in the sector, after the squad got removed
Parameters
index The index of the squad
callback onStartFiring(entityId)
Executed whenever an entity starts firing in the sector
Parameters
callback onStopFiring(entityId)
Executed whenever an entity stops firing in the sector
Parameters
callback onSystemsChanged(shipIndex)
Executed whenever the systems of a ship in the sector changed. This callback is executed *after* the system was changed on the entity.
Parameters
callback onSystemUpgradeLootCollected(collector, lootIndex)
Executed whenever system upgrade loot gets collected by an entity
Parameters
lootIndex The index of the loot that was collected
callback onTorpedoHit(objectIndex, shooterIndex, torpedoIndex)
Executed whenever a block object is hit by a torpedo in the sector.
Parameters
shooterIndex The index of the craft that fired the torpedo
torpedoIndex The index of the torpedo that hit the object
callback onTorpedoHullHit(objectIndex, blockIndex, shooterIndex, damage, torpedoIndex)
Executed whenever a block object is hit by a torpedo in the sector. Don't delete the block that is hit by the torpedo, this will lead to a crash.
Parameters
blockIndex The index of the block that was hit by the torpedo
shooterIndex The index of the craft that fired the torpedo
damage The damage the torpedo dealt to the object
torpedoIndex The index of the torpedo that hit the object
callback onTorpedoLaunched(entityId, torpedoId)
Executed whenever a torpedo was launched from an entity
Parameters
torpedoId The id of the launched torpedo
callback onTorpedoShieldHit(objectIndex, shooterIndex, damage, torpedoIndex)
Executed whenever an object's shield is hit by a torpedo in the sector.
Parameters
shooterIndex The index of the craft that fired the torpedo
damage The damage the torpedo dealt to the object
torpedoIndex The index of the torpedo that hit the object
callback onTurretAdded(shipIndex, turretIndex)
Executed whenever a turret was added to a ship in the sector
Parameters
turretIndex The index of the turret
callback onTurretDestroyed(turretIndex, shipIndex, lastDamageInflictor)
Executed whenever a turret was destroyed in the sector
Parameters
shipIndex The id of the entity that turret was attached to
lastDamageInflictor The index of the last entity that inflicted damage to the destroyed entity
callback onTurretLootCollected(collector, lootIndex)
Executed whenever turret loot gets collected by an entity controlled by AI
Parameters
lootIndex The index of the collected loot
callback onTurretRemoved(shipIndex, turretIndex)
Executed whenever a turret was removed in the sector
Parameters
turretIndex The index of the turret
callback onTurretRemovedByPlayer(shipIndex, turretIndex)
Executed whenever a turret was removed from a ship by the player in the sector
Parameters
turretIndex The index of the turret
callback onUndockedFromEntity(dockeeId, dockerId)
Executed whenever an entity was undocked from another entity
Parameters
dockerId The id of the docking entity (parent)
Callbacks Alliance [Client] Callbacks Alliance [Server] Callbacks Alliance [Server] Callbacks Entity Callbacks Galaxy Callbacks Player Callbacks Player [Client] Callbacks Sector Callbacks Server Callbacks
Command Entity FactionDatabase PlanGenerator Player Sector Server UsableInventoryItem
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
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
EntityIcon EntityTooltip PlanMesh ReadOnlyIcon ReadOnlyPlanMesh ReadOnlyScriptUI ReadOnlyTooltip ScriptUI
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
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
EntityTransferrer FighterController Loot ReadOnlyEntityTransferrer ReadOnlyFighterController ReadOnlyLoot ReadOnlyTurretController ReadOnlyWreckageCreator TurretController WreckageCreator
Alliance [Server] Faction [Server] Galaxy [Server] Player [Server] ReadOnlySector Sector [Server] Server ShipDatabaseEntry [Server]
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 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.7 c8e4beec84f7