Avorion Script API Documentation

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:

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