Avorion Script API Documentation
Player Script Predefined Functions
Tip: Scroll down for an example script!
function updateServer(timeStep)
Update tick that is only executed on the server. See the documentation for getUpdateInterval() for details on the frequency of these calls.
Server Function: This function is only called on the server.
Parameters
function updateServer(timeStep)
Update tick that is only executed on the server. See the documentation for getUpdateInterval() for details on the frequency of these calls.
Server Function: This function is only called on the server.
Parameters
function initialize(...)
This function is always the very first function that is called in a script, and only once during the lifetime of the script. The function is always called on the server first, before client instances are available, so invoking client functions will never work. This function is both called when a script gets newly attached to an object, and when the object is loaded from the database during a load from disk operation. During a load from disk operation, no parameters are passed to the function, and a global variable '_restoring' is set to true.
Parameters
function update(timeStep)
Called every tick, both on client and server. See the documentation for getUpdateInterval() for details on the frequency of these calls.
Parameters
function getUpdateInterval()
Defines the update tick interval of the script. This interval can not be less than the update tick interval of the server or client, depending on where the script is running. The update(), updateParallelRead(), updateParallelSelf(), updateClient() and updateServer() functions will only be called after at least this much time has passed. The minimum update interval for the client varies with the framerate of the client. The minimum update interval for the server is 50 ms. This function is called after initialize() or after the update functions were called. If this function is not defined, the update functions will be called every tick.
Expected return values
The desired update tick interval in seconds
function onRemove()
Called when the script is about to be removed from the object, before the removal.
function onDelete()
Called when the script is about to be deleted from the object, before the deletion. This is the last call that will be done to an object script. This function is also called when the object it is attached to is deleted.
function secure()
Called to secure values from the script. This function is called when the object is unloaded from the server. It's called at other times as well to refresh data, or when objects are copied or during regular saves. The table returned by this function will be passed to the restore() function when the object is loaded and read from disk. All values that are in the table must be numbers, strings or other tables. Values that aren't of the above types will be converted to nil and an error message will be printed.
Expected return values
A table containing values that should be saved
function restore(values)
Called to restore previously secured values for the script. This is called after initialize(). Receives the values that were gathered from the last called to the secure() function. This function is called when the object is read from disk and restored, after initialize() was called.
Parameters
function getMissionBrief()
A function that is used by the mission board to get the brief description of a mission. This function should return a string containing the brief description. If this function isn't defined, or if nothing or empty string is returned, the mission won't be displayed in the "Missions" tab.
Client Function: This function is only called on the client.
function getMissionDescription()
A function that is used by the mission board to get the long description of a mission. This function should return a string containing the description.
Client Function: This function is only called on the client.
function getMissionIcon()
A function that is used by the mission board to get the icon of a mission. This function should return a string containing the icon. Empty string means no icon.
Client Function: This function is only called on the client.
function getMissionPriority()
A function that is used by the mission board to get the priority (ie. rank on the mission board) of a mission. This function should return a number. The higher the number, the higher the rank on the mission board. Default: 0
Client Function: This function is only called on the client.
function getMissionLocation()
A function that is used by the mission board to get the sector location of a mission. This function should return 2 integer values containing the x and y location of the mission, or an arbitrary amount of ivec2's showing multiple locations for the mission. If this function isn't defined, or if not exactly 2 values are returned, the "Show Location" button in the "Missions" tab won't be active.
Client Function: This function is only called on the client.
function updateClient(timeStep)
Update tick that is only executed on the client. See the documentation for getUpdateInterval() for details on the frequency of these calls.
Client Function: This function is only called on the client.
Parameters
function updateClient(timeStep)
Update tick that is only executed on the Client. See the documentation for getUpdateInterval() for details on the frequency of these calls.
Client Function: This function is only called on the client.
Parameters
function abandon()
A function that is used by the mission board to abandon a mission. This function should do a remote function invocation to call terminate() on the server side, so that the mission script is removed from the player. If this function isn't defined then the mission won't be abandonable, and the "Abandon" button on the mission tab won't be active.
Client Function: This function is only called on the client.
function showMissionDetails()
A function that is used by the mission board to show more details of a mission. This function can be used as the mission script pleases. It could show a window, text message, or whatever fits the mission. If this function isn't defined then the "Details" button won't be shown in the UI.
Client Function: This function is only called on the client.
Player Example Script
-- Update tick that is only executed on the server. See the documentation for getUpdateInterval()
-- for details on the frequency of these calls.
-- Server Function: This function is only called on the server.
function updateServer(timeStep)
end
-- Update tick that is only executed on the server. See the documentation for getUpdateInterval()
-- for details on the frequency of these calls.
-- Server Function: This function is only called on the server.
function updateServer(timeStep)
end
-- This function is always the very first function that is called in a script, and only once during
-- the lifetime of the script. The function is always called on the server first, before client
-- instances are available, so invoking client functions will never work. This function is both
-- called when a script gets newly attached to an object, and when the object is loaded from the
-- database during a load from disk operation. During a load from disk operation, no parameters
-- are passed to the function, and a global variable '_restoring' is set to true.
function initialize(...)
end
-- Called every tick, both on client and server. See the documentation for getUpdateInterval()
-- for details on the frequency of these calls.
function update(timeStep)
end
-- Defines the update tick interval of the script. This interval can not be less than the update
-- tick interval of the server or client, depending on where the script is running. The update(),
-- updateParallelRead(), updateParallelSelf(), updateClient() and updateServer() functions will
-- only be called after at least this much time has passed. The minimum update interval for the
-- client varies with the framerate of the client. The minimum update interval for the server
-- is 50 ms. This function is called after initialize() or after the update functions were called.
-- If this function is not defined, the update functions will be called every tick.
function getUpdateInterval()
end
-- Called when the script is about to be removed from the object, before the removal.
function onRemove()
end
-- Called when the script is about to be deleted from the object, before the deletion. This is
-- the last call that will be done to an object script. This function is also called when the
-- object it is attached to is deleted.
function onDelete()
end
-- Called to secure values from the script. This function is called when the object is unloaded
-- from the server. It's called at other times as well to refresh data, or when objects are copied
-- or during regular saves. The table returned by this function will be passed to the restore()
-- function when the object is loaded and read from disk. All values that are in the table must
-- be numbers, strings or other tables. Values that aren't of the above types will be converted
-- to nil and an error message will be printed.
function secure()
end
-- Called to restore previously secured values for the script. This is called after initialize().
-- Receives the values that were gathered from the last called to the secure() function. This
-- function is called when the object is read from disk and restored, after initialize() was called.
function restore(values)
end
-- A function that is used by the mission board to get the brief description of a mission. This
-- function should return a string containing the brief description. If this function isn't defined,
-- or if nothing or empty string is returned, the mission won't be displayed in the "Missions"
-- tab.
-- Client Function: This function is only called on the client.
function getMissionBrief()
end
-- A function that is used by the mission board to get the long description of a mission. This
-- function should return a string containing the description.
-- Client Function: This function is only called on the client.
function getMissionDescription()
end
-- A function that is used by the mission board to get the icon of a mission. This function should
-- return a string containing the icon. Empty string means no icon.
-- Client Function: This function is only called on the client.
function getMissionIcon()
end
-- A function that is used by the mission board to get the priority (ie. rank on the mission board)
-- of a mission. This function should return a number. The higher the number, the higher the rank
-- on the mission board. Default: 0
-- Client Function: This function is only called on the client.
function getMissionPriority()
end
-- A function that is used by the mission board to get the sector location of a mission. This
-- function should return 2 integer values containing the x and y location of the mission, or
-- an arbitrary amount of ivec2's showing multiple locations for the mission. If this function
-- isn't defined, or if not exactly 2 values are returned, the "Show Location" button in the "Missions"
-- tab won't be active.
-- Client Function: This function is only called on the client.
function getMissionLocation()
end
-- Update tick that is only executed on the client. See the documentation for getUpdateInterval()
-- for details on the frequency of these calls.
-- Client Function: This function is only called on the client.
function updateClient(timeStep)
end
-- Update tick that is only executed on the Client. See the documentation for getUpdateInterval()
-- for details on the frequency of these calls.
-- Client Function: This function is only called on the client.
function updateClient(timeStep)
end
-- A function that is used by the mission board to abandon a mission. This function should do
-- a remote function invocation to call terminate() on the server side, so that the mission script
-- is removed from the player. If this function isn't defined then the mission won't be abandonable,
-- and the "Abandon" button on the mission tab won't be active.
-- Client Function: This function is only called on the client.
function abandon()
end
-- A function that is used by the mission board to show more details of a mission. This function
-- can be used as the mission script pleases. It could show a window, text message, or whatever
-- fits the mission. If this function isn't defined then the "Details" button won't be shown in
-- the UI.
-- Client Function: This function is only called on the client.
function showMissionDetails()
end
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