Avorion Script API Documentation

ControlUnit

function ControlUnit(var id)

Parameters

id The id of the entity this component belongs to, or the entity itself, must be an id of an existing entity or nil for the entity in the current script context

Returns

A new instance of ControlUnit

property bool autoPilotEnabled
property float desiredVelocity[read-only]
The current velocity the ship is trying to fly from 0 to 1, where 0 means standstill and 1 means the maximum speed the ship can fly without boosting.
property Entity entity[read-only]
property uuid entityId[read-only]
property bool hasPilot[read-only]
property bool isBoosting[read-only]
property bool isDrifting[read-only]
property bool isStrafing[read-only]
property bool isTurning[read-only]
property int numFreeSeats[read-only]
property int numOccupiedSeats[read-only]
property vec3 turningSpeedFactor[read-only]
A vec3 containing the turning speed multipliers for axis x, y, z. The turning speed factor is a multiplier for the turning speed of a ship, and is set in flyToLocation(), to smoothen turning once the ship looks towards its target (to avoid jittering).

function var addSeat()

Adds a new seat.

Returns

nothing

function var addSeatSquad(int seatIndex, int fighterSquadIndex)

Adds a new fighter squad for a given seat.

Parameters

seatIndex The index of the seat (0-9)
fighterSquadIndex The index of the fighter squad (0-9)

Returns

nothing

function var addSeatWeaponGroup(int seatIndex, int weaponGroupIndex)

Adds a new weapon group for a given seat.

Parameters

seatIndex The index of the seat (0-9)
weaponGroupIndex The index of the weapon group (0-9)

Returns

nothing

function var driftToLocation(vec3 location)

Executes the button presses necessary to have the ship drift to the target location. Drifting to a location means using only thrusters and not the main engine. This function must be called every tick in order to work correctly.

Parameters

location The target location to drift towards.

Returns

nothing

function var flyToLocation(vec3 location, float velocityAtTarget)

Executes the button presses necessary to have the ship turn and fly to the target location. This function must be called every tick in order to work correctly.

Parameters

location The target location to fly towards
velocityAtTarget The physical velocity that the ship should have when arriving at its destination. Use real velocity (m/s) here, not desired velocity (0% - 100%)

Returns

nothing

function bitset<10> getActiveWeapons()

Returns a list of bools representing the currently active weapon groups.

function vec3 getAimedPositionBySeat(int seatIndex)

Returns the aimed position of a given seat.

Parameters

seatIndex The index of the seat

function vec3 getAimedPositionByWeaponGroup(int groupIndex)

Returns the aimed position of the seat that controls the given weapon group.

Parameters

groupIndex The weapon group of the seat

function vec3... getAimedPositions()

Returns a list of aimed positions of all seats

function int... getAllControlActions()

Returns a list of bitsets (represented as ints) of control actions of all seats.

function int getControlActions(int seatIndex)

Returns the bitset of control actions of a given seat.

Parameters

seatIndex The index of the seat

function int getControlActionsByWeaponGroup(int groupIndex)

Returns the bitset of control actions of the seat that controls the given weapon group.

Parameters

groupIndex The weapon group of the seat

function vec3 getFlownToLocation()

Returns the currently flown to location, which is set by calls to flyToLocation. Note: When the AI flies towards a location, it also sets this.

function int getSeatByWeaponGroup(int groupIndex)

Returns the seat that controls a particular weapon group.

Parameters

groupIndex The weapon group of the seat

function ControlUnitSeat... getSeats()

Returns a list of seats of the control unit.

function Entity getSelectedObject(int seatIndex)

Returns the selected object of a given seat.

Parameters

seatIndex The index of the seat

function uuid getSelectedObjectId(int seatIndex)

Returns the id of the selected object of a given seat.

Parameters

seatIndex The index of the seat

function uuid... getSelectedObjectIds()

Returns a list of selected target ids of all seats

function bool isFiring(int seat)

Checks if the given seat is currently pushing "Fire" (see ControlActionBit.Fire1)

function bool isFiringTorpedoes(int seat)

Checks if the given seat is currently pushing "Fire Torpedoes" (see ControlActionBit.Fire2)

function bool isPlayerAPilot(int playerIndex)

Checks if the given player is setting in any seat of the control unit.

Parameters

playerIndex The index of the player

function bool mayControlSquad(int playerIndex, int squadIndex)

Checks if the given player has the right to control the given fighter squad.

Parameters

playerIndex The index of the player
squadIndex The index of the squad

function bool mayControlWeaponGroup(int playerIndex, int groupIndex)

Checks if the given player has the right to control the given weapon group.

Parameters

playerIndex The index of the player
groupIndex The index of the weapon group

function bool maySteer(int playerIndex)

Checks if the given player has the right to pilot (steer) the ship. The player must be sitting in the pilot seat.

Parameters

playerIndex The index of the player

function var removeSeat(int seatIndex)

Removes the given seat. Seat 0 can't be removed.

Parameters

seatIndex The seat index between 1 and the amount of seats minus 1

Returns

nothing

function var setAimedPosition(vec3 location, int seatIndex)

Sets the current position that the non-independent turrets of the ship should aim at. This is, for example, what is set when the player aims.

Parameters

location The location that the turrets should aim at
seatIndex The seat that the position should be set for

Returns

nothing

function var setControlActions(int mask, int seatIndex)

Sets the current control actions of the ship. A control action is basically a virtual button that is pressed on the control unit.

Parameters

mask A bitset of buttons that are pressed (see ControlActionBit)
seatIndex The seat that the control actions should be set for

Returns

nothing

function var setDesiredVelocity(float desiredVelocity)

Sets the desired velocity of the ship. Desired velocity is measured from 0 (standstill) to 1 (maximum speed the ship can fly). The engine of the ship will accelerate normally until the desired velocity is reached. This will not influence boosting.

Parameters

desiredVelocity The desired velocity to use (0 to 1)

Returns

nothing

function var setKeyDownMask(int mask, int seatIndex)

Enables control actions of the ship. A control action is basically a virtual button that is pressed on the control unit. This function presses them (as in: pushes them down).

Parameters

mask A bitset of buttons that are pressed (see ControlActionBit)
seatIndex The seat that the control actions should be set for

Returns

nothing

function var setKeyUpMask(int mask, int seatIndex)

Disables control actions of the ship. A control action is basically a virtual button that is pressed on the control unit. This function releases them.

Parameters

mask A bitset of buttons that are released (see ControlActionBit)
seatIndex The seat that the control actions should be set for

Returns

nothing

function var setSelectedObjectId(Uuid location, int seatIndex)

Sets the current position that the non-independent turrets of the ship should aim at. This is, for example, what is set when the player aims.

Parameters

location The location that the turrets should aim at
seatIndex The seat that the position should be set for

Returns

nothing

function var setTurningSpeedFactor(vec3 factor)

Sets the current turning speed factor. The turning speed factor is a multiplier for the turning speed of a ship, used in flyToLocation(), to smoothen turning once the ship looks towards its target (to avoid jittering). It is set during flyToLocation(), so make sure to set it to (1, 1, 1) if you want to control the ship yourself.

Parameters

factor A vec3 containing the turning speed multipliers for axis x, y, z

Returns

nothing

function var stopShip()

Releases all buttons and sets the ship's desired velocity to 0.

Returns

nothing

function var stopSteering()

Releases all buttons but keeps the ship's desired velocity.

Returns

nothing

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