# Avorion Script API Documentation

Home Functions Search
Search:

Server Server
Properties
accessMode
collisionDamage
description
difficulty
folder
gamePort
generatorThreads
infiniteResources
maxPlayers
name
numAdministrators
paused
players
playerToPlayerDamage
rconPort
runtime
sameStartSector
scriptThreads
seed
sessionId
steamMasterPort
steamQueryPort
udpPollingPort
unpausedRuntime
workerThreads
xsotanInvasionSectors
Member Functions
addChatCommand
broadcastChatMessage
callbacksRegistered
getBlackList
getIpBlackList
getOnlinePlayers
getPlayers
getValue
getValues
getWhiteList
hasAdminPrivileges
isOnline
registerCallback
removeBlacklistedIp
removeBlacklistedName
removeWhitelistedName
save
sendCallback
setValue
stop
unregisterCallback

# Server

This object is only available on the server.

function Server()

Returns

A new instance of Server

property int accessMode | [read-only]

property float collisionDamage | [read-only]

property string description | [read-only]

property int difficulty | [read-only]

property string folder | [read-only]

property int gamePort | [read-only]

property int generatorThreads | [read-only]

property bool infiniteResources | [read-only]

property int maxPlayers | [read-only]

property string name | [read-only]

property const numAdministrators | [read-only]

property double paused | [read-only]

property int players | [read-only]

property bool playerToPlayerDamage |

property int rconPort | [read-only]

property double runtime | [read-only]

property bool sameStartSector | [read-only]

property int scriptThreads | [read-only]

property Seed seed | [read-only]

property var sessionId | [read-only]

property int steamMasterPort | [read-only]

property int steamQueryPort | [read-only]

property int udpPollingPort | [read-only]

property double unpausedRuntime | [read-only]

property int workerThreads | [read-only]

property int xsotanInvasionSectors | [read-only]

function var addChatCommand(Player sender, string command)

Returns

nothing

function var broadcastChatMessage(var sender, int messageType, string message, PluralForm... args)

Broadcast a chat message to all players on the server. Supports sending of format arguments so that the message can be translated on the client.

Parameters

sender The sender that will be displayed for the chat message
messageType The type of chat message, 0 = Normal, 1 = Error, 2 = Warning, 3 = Info
message The message that will be sent
args The format arguments that will be sent

Returns

nothing

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. -1 if an error occurred.

function string... getBlackList()

function string... getIpBlackList()

function Player... getOnlinePlayers()

function Player... getPlayers()

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 of the entity

Returns

A table containing all custom key-value pairs

function string... getWhiteList()

function bool hasAdminPrivileges(Player player)

function bool isOnline(int index)

Checks if the player or the alliance with the given index is currently online. An alliance counts as online if at least one member is online.

Parameters

index The index of the player or alliance

Returns

true if online, false otherwise

function int registerCallback(string callbackName, string functionName)

Register a callback in the server. The callback may arrive with a delay. 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

0 on success, 1 if the registration failed

function var removeBlacklistedIp(string ip)

Returns

nothing

function var removeBlacklistedName(string name)

Returns

nothing

function var removeWhitelistedName(string name)

Returns

nothing

function var save()

Returns

nothing

function var sendCallback()

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.

function var stop()

Returns

nothing

function int unregisterCallback(string callbackName, string functionName)

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