Avorion Script API Documentation
CargoBay
This represents an interface to an entity in the scene. Creating an object of this type will not
create a
new entity in the scene, but will rather enable access to an existing entity. Use the Sector class
to
create new entities.
Avorion uses an entity component system (See entity component system on
Wikipedia). Thus, some properties and functions are only available if the entity has the
corresponding component. The list of components can be found here: Enum ComponentType
Note:
The id property of an Entity can be changed, but won't change the actual id of the underlying
entity. Instead, the entity interface will be pointing to another entity with the new id. Use this
for
performance tuning to avoid creating lots of entity interfaces.
Note 2: This class is
considered
to have too many members and functions. Over time these will be phased out into their respective
component classes. Only a few frequently used properties and functions will remain for coding
comfort.
function CargoBay(string name, string plural, string description, string icon, float price, float size)
Parameters
Returns
A new instance of CargoBay
property bool alwaysStoreAtLeastOne |
property float cargoHold |
property float cargoVolume | [read-only] |
property bool empty | [read-only] |
property Entity entity | [read-only] |
property uuid entityId | [read-only] |
property bool fixedSize |
property float freeSpace | [read-only] |
property int numCargos | [read-only] |
property bool pickUpDangerous |
property bool pickUpDefaults |
property bool pickUpIllegal |
property bool pickUpOres |
property bool pickUpScrap |
property bool pickUpStolen |
property float accuracy | [read-only] |
property bool ancient |
property bool armed | [read-only] |
property int averageTech | [read-only] |
property float baseEnergyPerSecond |
property float bestEfficiency | [read-only] |
property bool blackMarketDLCOnly | [read-only] |
property WeaponCategory category | [read-only] |
property bool civil | [read-only] |
property bool coaxial |
property bool continuousBeam | [read-only] |
property float coolingRate |
property float coolingTime | [read-only] |
property int coolingType |
property Crew crew |
property float damage | [read-only] |
property int damageType | [read-only] |
property bool deathExplosion | [read-only] |
property float dps | [read-only] |
property float energyIncreasePerSecond |
property bool favorite |
property float fireRate | [read-only] |
property bool firing |
property float firingsPerSecond | [read-only] |
property var flavorText |
property float heat | [read-only] |
property float heatPerShot |
property float holdingForce | [read-only] |
property float hullDamageMultiplicator | [read-only] |
property float hullDamageMultiplier | [read-only] |
property float hullRepairRate | [read-only] |
property bool intoTheRiftDLCOnly | [read-only] |
property int itemType | [read-only] |
property Material material | [read-only] |
property float maxHeat |
property int maxTech | [read-only] |
property float metalBestEfficiency | [read-only] |
property float metalRawEfficiency | [read-only] |
property float metalRefinedEfficiency | [read-only] |
property bool missionRelevant |
property var name | [read-only] |
property int numVisibleWeapons | [read-only] |
property int numWeapons | [read-only] |
property float otherForce | [read-only] |
property bool overheated | [read-only] |
property Rarity rarity | [read-only] |
property float reach | [read-only] |
property bool recent |
property double requiredShootingEnergy | [read-only] |
property bool seeker | [read-only] |
property float selfForce | [read-only] |
property float shieldDamageMultiplicator | [read-only] |
property float shieldDamageMultiplier | [read-only] |
property float shieldPenetration | [read-only] |
property float shieldRepairRate | [read-only] |
property float shootingTime | [read-only] |
property float shotSpeed | [read-only] |
property int shotsPerFiring | [read-only] |
property float shotsPerSecond | [read-only] |
property int shotsUntilOverheated | [read-only] |
property bool simultaneousShooting |
property float size |
property int slots |
property TurretSlotType slotType |
property bool stackable | [read-only] |
property float stoneBestEfficiency | [read-only] |
property float stoneDamageMultiplicator | [read-only] |
property float stoneDamageMultiplier | [read-only] |
property float stoneRawEfficiency | [read-only] |
property float stoneRefinedEfficiency | [read-only] |
property var title |
property bool trash |
property float turningSpeed |
property string weaponIcon | [read-only] |
property string weaponName | [read-only] |
property string weaponPrefix | [read-only] |
property bool includeCrew |
property bool includeEnergy |
property bool includeUpgrades |
property bool aiOwned | [read-only] |
property bool allianceOwned | [read-only] |
property bool canPassRifts | [read-only] |
property int controlActions |
property Crew crew |
property var crewSize | [read-only] |
property float damageMultiplier |
property float desiredVelocity |
property bool dockable |
property Uuid dockingParent | [read-only] |
property double durability |
property int excludedPlayer |
property int exclusionTime |
property int factionIndex |
property bool fighterCargoPickup | [read-only] |
property double firePower | [read-only] |
property var freeCargoSpace | [read-only] |
property bool hasPilot | [read-only] |
property float hyperspaceCooldown |
property float hyperspaceJumpReach |
property Uuid id | [read-only] |
property Crew idealCrew | [read-only] |
property Uuid index | [read-only] |
property bool invincible |
property bool isAnomaly | [read-only] |
property var isArmedTurret | [read-only] |
property bool isAsteroid | [read-only] |
property bool isContainer | [read-only] |
property bool isDrone | [read-only] |
property bool isFighter | [read-only] |
property bool isFlyable | [read-only] |
property bool isLoot | [read-only] |
property bool isObviouslyMineable |
property bool isOther | [read-only] |
property var isShieldActive | [read-only] |
property bool isShip | [read-only] |
property bool isStation | [read-only] |
property var isTurning | [read-only] |
property bool isTurret | [read-only] |
property var isUnarmedTurret | [read-only] |
property bool isUnknown | [read-only] |
property bool isWormHole | [read-only] |
property bool isWreckage | [read-only] |
property vec3 look | [read-only] |
property var mass | [read-only] |
property var maxCargoSpace | [read-only] |
property var maxCrewSize | [read-only] |
property var maxDurability | [read-only] |
property Crew minCrew | [read-only] |
property Entity mothership |
property string name |
property int numCargos | [read-only] |
property int numDefenseWeapons | [read-only] |
property int numDefenseWeaponsCurrentAttack | [read-only] |
property var numDockingPositions | [read-only] |
property var numTurrets | [read-only] |
property var occupiedCargoSpace | [read-only] |
property Matrix orientation |
property bool playerOrAllianceOwned | [read-only] |
property bool playerOwned | [read-only] |
property Matrix position |
property var radius | [read-only] |
property float reservationTime |
property int reservedPlayer |
property vec3 right | [read-only] |
property var selectedObject |
property double shieldDurability |
property double shieldMaxDurability |
property float shieldMeshIntensity | [read-only] |
property vec3 size | [read-only] |
property var timeAlive | [read-only] |
property string title |
property var translatedTitle | [read-only] |
property dvec3 translation |
property vec3 translationf | [read-only] |
property double transporterRange | [read-only] |
property int type |
property string typename | [read-only] |
property vec3 up | [read-only] |
property var volume | [read-only] |
property bool aiOwned | [read-only] |
property bool allianceOwned | [read-only] |
property bool canPassRifts | [read-only] |
property int controlActions |
property Crew crew |
property var crewSize | [read-only] |
property float damageMultiplier |
property float desiredVelocity |
property bool dockable |
property Uuid dockingParent | [read-only] |
property double durability |
property int excludedPlayer |
property int exclusionTime |
property int factionIndex |
property bool fighterCargoPickup | [read-only] |
property double firePower | [read-only] |
property var freeCargoSpace | [read-only] |
property bool hasPilot | [read-only] |
property float hyperspaceCooldown |
property float hyperspaceJumpReach |
property Uuid id | [read-only] |
property Crew idealCrew | [read-only] |
property Uuid index | [read-only] |
property bool invincible |
property bool isAnomaly | [read-only] |
property var isArmedTurret | [read-only] |
property bool isAsteroid | [read-only] |
property bool isContainer | [read-only] |
property bool isDrone | [read-only] |
property bool isFighter | [read-only] |
property bool isFlyable | [read-only] |
property bool isLoot | [read-only] |
property bool isObviouslyMineable |
property bool isOther | [read-only] |
property var isShieldActive | [read-only] |
property bool isShip | [read-only] |
property bool isStation | [read-only] |
property var isTurning | [read-only] |
property bool isTurret | [read-only] |
property var isUnarmedTurret | [read-only] |
property bool isUnknown | [read-only] |
property bool isWormHole | [read-only] |
property bool isWreckage | [read-only] |
property vec3 look | [read-only] |
property var mass | [read-only] |
property var maxCargoSpace | [read-only] |
property var maxCrewSize | [read-only] |
property var maxDurability | [read-only] |
property Crew minCrew | [read-only] |
property Entity mothership |
property string name |
property int numCargos | [read-only] |
property int numDefenseWeapons | [read-only] |
property int numDefenseWeaponsCurrentAttack | [read-only] |
property var numDockingPositions | [read-only] |
property var numTurrets | [read-only] |
property var occupiedCargoSpace | [read-only] |
property Matrix orientation |
property bool playerOrAllianceOwned | [read-only] |
property bool playerOwned | [read-only] |
property Matrix position |
property var radius | [read-only] |
property float reservationTime |
property int reservedPlayer |
property vec3 right | [read-only] |
property var selectedObject |
property double shieldDurability |
property double shieldMaxDurability |
property float shieldMeshIntensity | [read-only] |
property vec3 size | [read-only] |
property var timeAlive | [read-only] |
property string title |
property var translatedTitle | [read-only] |
property dvec3 translation |
property vec3 translationf | [read-only] |
property double transporterRange | [read-only] |
property int type |
property string typename | [read-only] |
property vec3 up | [read-only] |
property var volume | [read-only] |
property bool blocked | [read-only] |
property bool clearSpace | [read-only] |
property string consumerIcon | [read-only] |
property string consumerName | [read-only] |
property float cooldown | [read-only] |
property float cooldownSpeed | [read-only] |
property float currentCooldown | [read-only] |
property int defaultPriority | [read-only] |
property bool displayedCooldown | [read-only] |
property bool distorted | [read-only] |
property Entity entity | [read-only] |
property uuid entityId | [read-only] |
property bool isSceneEmpty | [read-only] |
property bool passBlocked | [read-only] |
property float range | [read-only] |
property double requiredEnergy | [read-only] |
property float requiredEnergyForJump | [read-only] |
property bool blocked | [read-only] |
property bool clearSpace |
property string consumerIcon | [read-only] |
property string consumerName | [read-only] |
property float cooldown |
property float cooldownSpeed | [read-only] |
property float currentCooldown |
property int defaultPriority | [read-only] |
property bool displayedCooldown | [read-only] |
property bool distorted | [read-only] |
property Entity entity | [read-only] |
property uuid entityId | [read-only] |
property bool isSceneEmpty | [read-only] |
property bool passBlocked |
property float range |
property double requiredEnergy | [read-only] |
property float requiredEnergyForJump | [read-only] |
property bool alwaysStoreAtLeastOne | [read-only] |
property float cargoHold | [read-only] |
property float cargoVolume | [read-only] |
property bool empty | [read-only] |
property Entity entity | [read-only] |
property uuid entityId | [read-only] |
property bool fixedSize | [read-only] |
property float freeSpace | [read-only] |
property int numCargos | [read-only] |
property bool pickUpDangerous | [read-only] |
property bool pickUpDefaults | [read-only] |
property bool pickUpIllegal | [read-only] |
property bool pickUpOres | [read-only] |
property bool pickUpScrap | [read-only] |
property bool pickUpStolen | [read-only] |
property bool autoPilotEnabled | [read-only] |
property float desiredVelocity | [read-only] |
property Entity entity | [read-only] |
property uuid a | [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] |
property bool alwaysStoreAtLeastOne |
property float cargoHold |
property float cargoVolume | [read-only] |
property bool empty | [read-only] |
property Entity entity | [read-only] |
property uuid a | [read-only] |
property bool fixedSize |
property float freeSpace | [read-only] |
property int numCargos | [read-only] |
property bool pickUpDangerous |
property bool pickUpDefaults |
property bool pickUpIllegal |
property bool pickUpOres |
property bool pickUpScrap |
property bool pickUpStolen |
property bool autoPilotEnabled |
property float desiredVelocity | [read-only] |
property Entity entity | [read-only] |
property uuid a | [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] |
property int numDocks | [read-only] |
function var add(CargoBay other)
Returns
nothing
function unsigned int addCargo(TradingGood
good, int amount)
Adds cargo to the entity. If the amount specified exceeds the maximum capacity of the cargo bay, as much cargo as still fits in will be added.
Parameters
amount The amount of cargo that should be added.
Returns
How much was actually added (can be less than amount when cargo bay is full)
function var clear()
Returns
nothing
function var destroyCargo(float volume)
Destroys cargo. The destruction distribution is generally equal over all goods.
Parameters
Returns
nothing
function table<TradingGood, int> findCargos(string name)
Finds all cargos with the given name.
Parameters
Returns
A map containing all matching goods, with the good as key and amount as value.
function TradingGood, int... getCargo(unsigned
int n)
function table<TradingGood, int> getCargos()
function int getNumCargos(var name)
Counts all goods of the given type. When given a string, it will match the 'name' property of the goods. When given a TradingGood it will match the exact good.
Parameters
Returns
The number of goods
function string getSummary(var goods)
function var removeCargo(var good, int amount)
Removes cargo from the entity. When given a TradingGood, an exact check for that good will be performed. When given a string, only a name check will be performed, and which cargo will be removed first is undefined if there are multiple goods with the same name. An example would be Energy Cells vs. Stolen Energy Cells. The 'name' property is the same, but the 'stolen' property is different.
Parameters
amount The amount of cargo that should be removed. If this is more than there is on the ship, all specified cargo will be removed.
Returns
nothing
function bool __eq(var other)
function var addDescription(string
str, string value)
Returns
nothing
function var addWeapon(var weapon)
Returns
nothing
function var clearDescriptions()
Returns
nothing
function var clearWeapons()
Returns
nothing
function Crew getCrew()
function table<string, string> getDescriptions()
function Weapon... getWeapons()
Returns all weapons of the object
function var setBlackMarketDLCOnly()
Returns
nothing
function var setIntoTheRiftDLCOnly()
Returns
nothing
function var setRange(float range)
Returns
nothing
function TurretTemplate template()
function var updateStaticStats()
Returns
nothing
function float getEfficiency(CraftStatsOverview::Stat stat)
function string getUnit(CraftStatsOverview::Stat stat)
function var getValue(CraftStatsOverview::Stat key)
function bool isBadValue(CraftStatsOverview::Stat stat)
function bool isDangerousValue(CraftStatsOverview::Stat stat)
function bool isRelevant(CraftStatsOverview::Stat stat)
function var setIncludeImpact(bool
crew, bool energy, bool upgrades)
Returns
nothing
function var update(Entity entity)
Returns
nothing
function var addComponent(Type type)
Returns
nothing
function var addComponents()
Returns
nothing
function UserObject getComponent(Type
type)
function var removeComponent(Type
type)
Returns
nothing
function var addAbsoluteBias(int
type, float value)
Adds a flat bias for stat of type type. This bias will be added to stat after multipliers are considered. Inherited from Entity
Parameters
value Bias added to base stats.
Returns
key that can be used to access the multiplier
function var addBaseMultiplier(int
type, float factor)
Adds a multiplyer for stat of type type. This is to increase a stat, so a factor of 0.3 will become 1.3. Inherited from Entity
Parameters
factor Factor that is used as Multiplier
Returns
key that can be used to access the multiplier
function unsigned int addCargo(TradingGood
good, int amount)
Adds cargo to the entity. If the amount specified exceeds the maximum capacity of the cargo bay, as much cargo as still fits in will be added. Inherited from Entity
Parameters
amount The amount of cargo that should be added.
Returns
How much was actually added (can be less than amount when cargo bay is full)
function var addCrew(int number, CrewMan crewman)
function var addKeyedAbsoluteBias(int
type, int key,
float value)
Exchanges flat bias at key with new value Inherited from Entity
Parameters
key Location of the bonus that will be changed
value New value
Returns
key that can be used to access the multiplier
function var addKeyedBaseMultiplier(int
type, int key, float value)
Exchanges multiplier at key with new value Inherited from Entity
Parameters
key Location of the bonus that will be changed
value New value
Returns
key that can be used to access the multiplier
function var addKeyedMultiplier(int
type, int key,
float value)
Exchanges multiplier at key with new value Inherited from Entity
Parameters
key Location of the bonus that will be changed
value New value
Returns
key that can be used to access the multiplier
function var addKeyedMultiplyableBias(int
type, int key, float value)
Exchanges bias at key with new value Inherited from Entity
Parameters
key Location of the bonus that will be changed
value New value
Returns
key that can be used to access the multiplier
function var addMultiplier(int type, float factor)
Adds a multiplyer for stat of type type. The factor will be used unchanged. Inherited from Entity
Parameters
factor Factor that is used as Multiplier
Returns
key that can be used to access the multiplier
function var addMultiplyableBias(int
type, float value)
Adds a bias for stat of type type. This bias will be added to stat before multipliers are considered. Inherited from Entity
Parameters
value Bias added to base stats.
Returns
key that can be used to access the multiplier
function var addScript(string scriptPath, var... arguments)
Adds a new script to an entity Inherited from Entity
Parameters
arguments An arbitrary number of arguments that will be given to the 'initialize' function of the added script
Returns
0 on success, 1 if the entity could not be found
function var addScriptOnce()
Inherited from Entity
function Uuid addTurret(TurretTemplate turret, Matrix position, int part)
Inherited from Entity
function var blockHyperspace(float
time)
function int callbacksRegistered(string
callbackName, var functionName)
Check how many functions are registered to a callback from the current script VM. Inherited from Entity
Parameters
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
function var, var, table<int, string> canAddCrew(int number, int
profession, bool change)
Inherited from Entity
function var changeCrew(int number, int profession)
function var changeShield(double
delta)
function var clearCargoBay()
function var clearValues()
function var damageShield(double
amount, vec3 location, Uuid inflictorId, var damageSource, var damageType)
Damages shield by delta amount, location and inflictorId are not necessary, but can be added if it is needed, e.g. you want to do effects on hitpoint. Inherited from Entity
Parameters
location
inflictorId
Returns
nothing
function var destroy(Uuid inflictorId, var damageSource, var damageType)
Destroy entity by inflicting more damage than durability of entity Inherited from Entity
Parameters
damageSource Source of damage. Can be Weaponry, Collision, Decay, Torpedo or Arbitrary. *
damageType Type of damage received. Damage can be of type Physical, Energy, Electric, Plasma, AntiMatter or Fragments.
Returns
nothing
function var destroyBlock(int index, Uuid inflictorId, var damageSource)
Destroy one block Inherited from Entity
Parameters
inflictorId Index of the entity that destroys the block
damageSource Source of damage. Can be Weaponry, Collision, Decay, Torpedo or Arbitrary.
Returns
nothing
function var destroyCargo(float volume)
Destroys cargo. The destruction distribution is generally equal over all goods. Inherited from Entity
Parameters
Returns
nothing
function var disableFlightAssistFor(float
time)
function var distortHyperspace(float
time)
function table<TradingGood, int> findCargos(string name)
Finds all cargos with the given name. Inherited from Entity
Parameters
Returns
A map containing all matching goods, with the good as key and amount as value.
function vec3 getAimedPositionBySeat(int
seat)
Inherited from Entity
function vec3... getAimedPositions()
Inherited from Entity
function var getAllowedArbitraryTurrets()
Inherited from Entity
function var getAllowedArmedTurrets()
Inherited from Entity
function var getAllowedUnarmedTurrets()
Inherited from Entity
function var getAttachedBlockIndex()
Returns the Index of the block that the turret is build on Inherited from Entity
function var getBoostedValue(int
type, float value)
Returns value with included bonus, in case a bonus exists. Returns Nil if no bonuses at all, returns value if no bonuses for this stat exist. Inherited from Entity
Parameters
value the value, that might be changed by bonuses
function Box getBoundingBox()
Returns Bounding Box for entity, use this if you need exact Bounding Box, e.g. for collision detection when entities are close to each other. Inherited from Entity
function Sphere getBoundingSphere()
Returns Bounding Sphere for entity. Much faster than Bounding Box, but not as accurate. Use this if you need to check often. Inherited from Entity
function Captain getCaptain()
Inherited from Entity
function TradingGood, int... getCargo(unsigned
int n)
Inherited from Entity
function int getCargoAmount(var name)
Counts all goods of the given type. When given a string, it will match the 'name' property of the goods. When given a TradingGood it will match the exact good. Inherited from Entity
Parameters
Returns
The number of goods
function table<TradingGood, int> getCargos()
Inherited from Entity
function var getCrewMembers(int profession)
Inherited from Entity
function int... getDamageContributorPlayerFactions()
Lists all players and alliances that contributed damage to the entity Inherited from Entity
Returns
Indices of all players and alliances that contributed damage to the entity
function int... getDamageContributorPlayers()
Lists all players that contributed damage to the entity Inherited from Entity
Returns
Indices of all players that contributed damage to the entity
function int... getDamageContributors()
Lists all factions that contributed damage to the entity Inherited from Entity
Returns
Indices of all factions that contributed damage to the entity
function Box getDockedGroupBoundingBox()
Returns Bounding Box for entity, but enlarged to also fit around all docked objects. Use this if you need exact Bounding Box, e.g. for collision detection when entities are close to each other. Inherited from Entity
function Sphere getDockedGroupBoundingSphere()
Returns Bounding Box for entity, but enlarged to also fit around all docked objects. Use this if you need exact Bounding Box, e.g. for collision detection when entities are close to each other. Inherited from Entity
function var getDockingPositions()
Lists all docking positions that the entity has Inherited from Entity
Returns
A table that contains a key-value pair (id, table) for each dock:
function var getFreeArbitraryTurrets()
Inherited from Entity
function var getFreeArmedTurrets()
Inherited from Entity
function var getFreeUnarmedTurrets()
Inherited from Entity
function BlockPlan getFullPlanCopy()
Returns the plan of the entity. This copies the entire plan, keep that in mind when using plans with large block counts. Inherited from Entity
Returns
A copy of the plan of the entity
function Material getLowestMineableMaterial()
Inherited from Entity
function var, var getMalusFactor()
Inherited from Entity
function Material getMineableMaterial()
Inherited from Entity
function int... getMineableResources()
Inherited from Entity
function int getMoneyLootAmount()
Inherited from Entity
function BlockPlan getMovePlan()
Returns the plan of the entity. This function will move the plan out of the entity, and replace the entity's plan with a single block. This operation is independent of the size of the plan, use it when you have to get large plans with lots of blocks. Inherited from Entity
Returns
The plan of the entity
function var getNearestDistance(Entity other)
Inherited from Entity
function var getNumArmedTurrets()
Inherited from Entity
function var getNumMiningTurrets()
Inherited from Entity
function var getNumSalvagingTurrets()
Inherited from Entity
function var getNumUnarmedTurrets()
Inherited from Entity
function int... getPilotIndices()
Returns Indices of piloting players Inherited from Entity
Returns
multiple return values: indices of players
function var getPlanMoneyValue()
Inherited from Entity
function double... getPlanResourceValue()
Inherited from Entity
function int getResourceLootAmount()
Inherited from Entity
function table<int, string> getScripts()
Inherited from Entity
function table<string, string> getTitleArguments()
Retrieves the arguments to a title Inherited from Entity
function NamedFormat getTitleFormat()
Retrieves the title as NamedFormat Inherited from Entity
function Entity getTurret(int index)
Inherited from Entity
function Matrix, int... getTurretPositions(TurretTemplate turret, int number)
Inherited from Entity
function Matrix, int... getTurretPositionsLineOfSight(TurretTemplate turret, int number)
Inherited from Entity
function Entity... getTurrets()
Inherited from Entity
function var getTurretSize()
Inherited from Entity
function var getTurretTemplateSize()
Inherited from Entity
function var getTurretTurningSpeed()
Inherited from Entity
function var getUndamagedPlanMoneyValue()
Inherited from Entity
function double... getUndamagedPlanResourceValue()
Inherited from Entity
function var getValue(string key)
Retrieves a custom value saved in the entity with the given key Inherited from Entity
Parameters
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 Inherited from Entity
Returns
A table containing all custom key-value pairs
function bool hasComponent(int type)
Inherited from Entity
function var hasScript(string name)
Inherited from Entity
function var heal(float damage, int index, vec3 location, Uuid inflictorID)
Increases durability of the plan of the Entity Inherited from Entity
Parameters
index Index of the block that will be restored
location vector containing the hit point, if unknown/unnecessary use empty vector
inflictorID Index of the entity that heals
Returns
nothing
function var healShield(double delta)
function var hyperspaceBlocked()
Inherited from Entity
function var inflictDamage(float
damage, var damageSource, var damageType, int index, vec3 location, Uuid inflictorId)
Inflicts damage to the plan of the Entity Inherited from Entity
Parameters
damageSource The source of the damage. Can be Weaponry, Collision, Decay, Torpedo or Arbitrary.
damageType Type of damage received. Damage can be of type Physical, Energy, Electric, Plasma, AntiMatter or Fragments
index Index of the block that will receive the damage
location vector containing the hit point, if unknown / unnecessary use empty vector
inflictorId Index of the entity that caused the damage
Returns
nothing
function var... invokeFunction(var
scriptName, string functionName, var... arguments)
Invokes a function in a script of the entity. Use this function to invoke functions from one script in another script. The first return value of the function is an integer indicating whether or not the call was successful. When it was, this integer is followed by the return values of the invoked function. Inherited from Entity
Parameters
functionName The name of the function that will be executed
arguments An arbitrary list of arguments that will be given to the invoked function
Returns
Returns at least 1 value indicating if the call succeeded:
0 The call was
successful. In
this case, the return values of the script are returned in addition to the call result,
following the call result
1 The call failed because the entity with the specified
index
does not exist or has no Scripts component
2 The call failed because it came from
another
sector than the entity is in
3 The call failed because the given script was not
found in
the entity
4 The call failed because the given function was not found in the
script
5 The call failed because the script's state has errors and is invalid
function var isCollectable(Entity
entity)
Inherited from Entity
function bool isInDockingArea(Entity
other)
Inherited from Entity
function var isInsideShield(vec3
point)
Inherited from Entity
function bool, var isJumpRouteValid(int
fromX, int fromY, int toX, int toY)
Inherited from Entity
function var isManned()
Inherited from Entity
function var isTurretAllowed(TurretTemplate
ScriptTurretTemplate)
Tests if the maximum number of turrets of this kind is not reached Inherited from Entity
Parameters
function int jumpPossible(int x, int y)
Tests if the entity can jump to the specified coordinates Inherited from Entity
Parameters
y The y-coordinates of the target sector
Returns
Returns an error code:
-1 The entity doesn't have a hyperspace drive.
0 The
entity
can jump.
1 The hyperspace drive needs to recharge.
2 The target sector is
too far
away.
3 The entity is facing the wrong direction.
4 The hyperspace drive is
being
jammed.
function var moveBy(vec3 delta)
function int registerCallback(string
callbackName, string functionName)
Register a callback in the entity. The callback receiver has to be inside the same sector for the registration to succeed. The callback will be removed if either the entity or the receiver leaves the sector or gets destroyed. 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. Inherited from Entity
Parameters
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 registerDamage(Uuid
shooterId, double damage, DamageSource DamageSource)
Registers artificial damage as if the entity was damaged by the shooter Inherited from Entity
Parameters
damage The amount of damage inflicted
DamageSource The kind of source for the damage
Returns
nothing
function var removeBonus(int key)
function var removeCargo(var good, int amount)
Removes cargo from the entity. When given a TradingGood, an exact check for that good will be performed. When given a string, only a name check will be performed, and which cargo will be removed first is undefined if there are multiple goods with the same name. An example would be Energy Cells vs. Stolen Energy Cells. The 'name' property is the same, but the 'stolen' property is different. Inherited from Entity
Parameters
amount The amount of cargo that should be removed. If this is more than there is on the ship, all specified cargo will be removed.
Returns
nothing
function var removeCrew(int number, CrewMan crewman)
Inherited from Entity
function var removeScript(var script)
function var removeScriptBonuses()
function var resolveScriptPath(string
path)
Inherited from Entity
function bool sendCallback()
Inherited from Entity
function var setAccumulatingBlockHealth(bool
bool)
If AccumulatingBlockHealth is true, a block needs to take as much damage as would be necessary to destroy all its children before it itself is destroyed. If it is set to false, the entity's blocks will have only their own durability. Set it to false if you want your entity to easily break apart, e.g. for wreckages. Inherited from Entity
Parameters
Returns
nothing
function var setAimedPosition(int
seat, vec3 in)
function var setAttachedBlockIndex(int in)
function var setCaptain(Captain [or
nil]
captain)
function var setDamageTypeMultiplier(DamageType type, float factor)
function var setDropsAttachedTurrets(bool
bool)
Sets the entities' ability to drop its attached turrets. If set to true (default) the ship has a chance to drop a turret that's attached to it when it's destroyed. This is only enabled for NPC entities. Inherited from Entity
Parameters
Returns
nothing
function var setDropsLoot(bool bool)
Sets the entities' ability to drop normal loot. Affects dropping of money, resources, cargo, turrets and upgrades. 'Loot' component is not affected by this. Inherited from Entity
Parameters
Returns
nothing
function var setMalusFactor(float
in, int reason)
function var setManned(bool in)
function var setMovePlan(BlockPlan
plan)
Set the new plan of the entity. The entity will get deleted if the plan is empty. This moves all the data out of the plan that is used as the first argument. The content of the plan given as argument is then undefined, but still valid. It might be empty, it might contain the previous plan. This operation is independent of the size of the plan, use it when you have to set large plans with lots of blocks. Inherited from Entity
Parameters
Returns
nothing
function var setPlan(BlockPlan plan)
Set the new plan of the entity. The entity will get deleted if the plan is empty. This copies the entire plan that is given as argument, keep that in mind when setting plans with large block counts. Inherited from Entity
Parameters
Returns
nothing
function var setTitle(string title, string_pair... arguments)
Sets the title that can be used as title in menus Inherited from Entity
Parameters
arguments Set the string arguments (if format string is used) as vector of string_pair.
Returns
nothing
function var setTitleArguments(string_pair... arguments)
Sets the arguments to a title Inherited from Entity
Parameters
Returns
nothing
function var setTurretSize(float
in)
function var setTurretTurningSpeed(float
in)
function var setValue(string key, var value)
Sets a custom value Inherited from Entity
Parameters
value The value to save. Must be bool, number, string or nil. If nil is given, the value will be deleted.
function var singleFlyToLocationTick(vec3
location)
Tells the ship to fly to given location, directly and without pathfinding. Inherited from Entity
Parameters
Returns
nothing
function int unregisterCallback(string callbackName, string functionName)
Inherited from Entity
function var updateProductionCatchingUp(float float)
Simulates production catching up. This is used when ships return from the background simulation. Updates fighter production, academy and cloning. Inherited from Entity
Parameters
Returns
nothing
function var waitUntilAsyncWorkFinished(var
time)
function var addAbsoluteBias(int
type, float value)
Adds a flat bias for stat of type type. This bias will be added to stat after multipliers are considered.
Parameters
value Bias added to base stats.
Returns
key that can be used to access the multiplier
function var addBaseMultiplier(int
type, float factor)
Adds a multiplyer for stat of type type. This is to increase a stat, so a factor of 0.3 will become 1.3.
Parameters
factor Factor that is used as Multiplier
Returns
key that can be used to access the multiplier
function unsigned int addCargo(TradingGood
good, int amount)
Adds cargo to the entity. If the amount specified exceeds the maximum capacity of the cargo bay, as much cargo as still fits in will be added.
Parameters
amount The amount of cargo that should be added.
Returns
How much was actually added (can be less than amount when cargo bay is full)
function var addCrew(int number, CrewMan crewman)
Returns
nothing
function var addKeyedAbsoluteBias(int
type, int key,
float value)
Exchanges flat bias at key with new value
Parameters
key Location of the bonus that will be changed
value New value
Returns
key that can be used to access the multiplier
function var addKeyedBaseMultiplier(int
type, int key, float value)
Exchanges multiplier at key with new value
Parameters
key Location of the bonus that will be changed
value New value
Returns
key that can be used to access the multiplier
function var addKeyedMultiplier(int
type, int key,
float value)
Exchanges multiplier at key with new value
Parameters
key Location of the bonus that will be changed
value New value
Returns
key that can be used to access the multiplier
function var addKeyedMultiplyableBias(int
type, int key, float value)
Exchanges bias at key with new value
Parameters
key Location of the bonus that will be changed
value New value
Returns
key that can be used to access the multiplier
function var addMultiplier(int type, float factor)
Adds a multiplyer for stat of type type. The factor will be used unchanged.
Parameters
factor Factor that is used as Multiplier
Returns
key that can be used to access the multiplier
function var addMultiplyableBias(int
type, float value)
Adds a bias for stat of type type. This bias will be added to stat before multipliers are considered.
Parameters
value Bias added to base stats.
Returns
key that can be used to access the multiplier
function var addScript(string scriptPath, var... arguments)
Adds a new script to an entity
Parameters
arguments An arbitrary number of arguments that will be given to the 'initialize' function of the added script
Returns
0 on success, 1 if the entity could not be found
function var addScriptOnce()
function Uuid addTurret(TurretTemplate turret, Matrix position, int part)
function var blockHyperspace(float
time)
Returns
nothing
function int callbacksRegistered(string
callbackName, var functionName)
Check how many functions are registered to a callback from the current script VM.
Parameters
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
function var, var, table<int, string> canAddCrew(int number, int
profession, bool change)
function var changeCrew(int number, int profession)
Returns
nothing
function var changeShield(double
delta)
Adds delta to shield durability
Parameters
Returns
nothing
function var clearCargoBay()
Returns
nothing
function var clearValues()
Removes all custom values of the object
Returns
nothing
function var damageShield(double
amount, vec3 location, Uuid inflictorId, var damageSource, var damageType)
Damages shield by delta amount, location and inflictorId are not necessary, but can be added if it is needed, e.g. you want to do effects on hitpoint.
Parameters
location
inflictorId
Returns
nothing
function var destroy(Uuid inflictorId, var damageSource, var damageType)
Destroy entity by inflicting more damage than durability of entity
Parameters
damageSource Source of damage. Can be Weaponry, Collision, Decay, Torpedo or Arbitrary. *
damageType Type of damage received. Damage can be of type Physical, Energy, Electric, Plasma, AntiMatter or Fragments.
Returns
nothing
function var destroyBlock(int index, Uuid inflictorId, var damageSource)
Destroy one block
Parameters
inflictorId Index of the entity that destroys the block
damageSource Source of damage. Can be Weaponry, Collision, Decay, Torpedo or Arbitrary.
Returns
nothing
function var destroyCargo(float volume)
Destroys cargo. The destruction distribution is generally equal over all goods.
Parameters
Returns
nothing
function var disableFlightAssistFor(float
time)
Returns
nothing
function var distortHyperspace(float
time)
Returns
nothing
function table<TradingGood, int> findCargos(string name)
Finds all cargos with the given name.
Parameters
Returns
A map containing all matching goods, with the good as key and amount as value.
function vec3 getAimedPositionBySeat(int
seat)
function vec3... getAimedPositions()
function var getAllowedArbitraryTurrets()
function var getAllowedArmedTurrets()
function var getAllowedUnarmedTurrets()
function var getAttachedBlockIndex()
Returns the Index of the block that the turret is build on
function var getBoostedValue(int
type, float value)
Returns value with included bonus, in case a bonus exists. Returns Nil if no bonuses at all, returns value if no bonuses for this stat exist.
Parameters
value the value, that might be changed by bonuses
function Box getBoundingBox()
Returns Bounding Box for entity, use this if you need exact Bounding Box, e.g. for collision detection when entities are close to each other.
function Sphere getBoundingSphere()
Returns Bounding Sphere for entity. Much faster than Bounding Box, but not as accurate. Use this if you need to check often.
function Captain getCaptain()
function TradingGood, int... getCargo(unsigned
int n)
function int getCargoAmount(var name)
Counts all goods of the given type. When given a string, it will match the 'name' property of the goods. When given a TradingGood it will match the exact good.
Parameters
Returns
The number of goods
function table<TradingGood, int> getCargos()
function var getCrewMembers(int profession)
function int... getDamageContributorPlayerFactions()
Lists all players and alliances that contributed damage to the entity
Returns
Indices of all players and alliances that contributed damage to the entity
function int... getDamageContributorPlayers()
Lists all players that contributed damage to the entity
Returns
Indices of all players that contributed damage to the entity
function int... getDamageContributors()
Lists all factions that contributed damage to the entity
Returns
Indices of all factions that contributed damage to the entity
function Box getDockedGroupBoundingBox()
Returns Bounding Box for entity, but enlarged to also fit around all docked objects. Use this if you need exact Bounding Box, e.g. for collision detection when entities are close to each other.
function Sphere getDockedGroupBoundingSphere()
Returns Bounding Box for entity, but enlarged to also fit around all docked objects. Use this if you need exact Bounding Box, e.g. for collision detection when entities are close to each other.
function var getDockingPositions()
Lists all docking positions that the entity has
Returns
A table that contains a key-value pair (id, table) for each dock:
function var getFreeArbitraryTurrets()
function var getFreeArmedTurrets()
function var getFreeUnarmedTurrets()
function BlockPlan getFullPlanCopy()
Returns the plan of the entity. This copies the entire plan, keep that in mind when using plans with large block counts.
Returns
A copy of the plan of the entity
function Material getLowestMineableMaterial()
function var, var getMalusFactor()
function Material getMineableMaterial()
function int... getMineableResources()
function int getMoneyLootAmount()
function BlockPlan getMovePlan()
Returns the plan of the entity. This function will move the plan out of the entity, and replace the entity's plan with a single block. This operation is independent of the size of the plan, use it when you have to get large plans with lots of blocks.
Returns
The plan of the entity
function var getNearestDistance(Entity other)
function var getNumArmedTurrets()
function var getNumMiningTurrets()
function var getNumSalvagingTurrets()
function var getNumUnarmedTurrets()
function int... getPilotIndices()
Returns Indices of piloting players
Returns
multiple return values: indices of players
function var getPlanMoneyValue()
function double... getPlanResourceValue()
function int getResourceLootAmount()
function table<int, string> getScripts()
function table<string, string> getTitleArguments()
Retrieves the arguments to a title
function NamedFormat getTitleFormat()
Retrieves the title as NamedFormat
function Entity getTurret(int index)
function Matrix, int... getTurretPositions(TurretTemplate turret, int number)
function Matrix, int... getTurretPositionsLineOfSight(TurretTemplate turret, int number)
function Entity... getTurrets()
function var getTurretSize()
function var getTurretTemplateSize()
function var getTurretTurningSpeed()
function var getUndamagedPlanMoneyValue()
function double... getUndamagedPlanResourceValue()
function var getValue(string key)
Retrieves a custom value saved in the entity with the given key
Parameters
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 bool hasComponent(int type)
function var hasScript(string name)
function var heal(float damage, int index, vec3 location, Uuid inflictorID)
Increases durability of the plan of the Entity
Parameters
index Index of the block that will be restored
location vector containing the hit point, if unknown/unnecessary use empty vector
inflictorID Index of the entity that heals
Returns
nothing
function var healShield(double delta)
Increases shield durability by delta
Parameters
Returns
nothing
function var hyperspaceBlocked()
function var inflictDamage(float
damage, var damageSource, var damageType, int index, vec3 location, Uuid inflictorId)
Inflicts damage to the plan of the Entity
Parameters
damageSource The source of the damage. Can be Weaponry, Collision, Decay, Torpedo or Arbitrary.
damageType Type of damage received. Damage can be of type Physical, Energy, Electric, Plasma, AntiMatter or Fragments
index Index of the block that will receive the damage
location vector containing the hit point, if unknown / unnecessary use empty vector
inflictorId Index of the entity that caused the damage
Returns
nothing
function var... invokeFunction(var
scriptName, string functionName, var... arguments)
Invokes a function in a script of the entity. Use this function to invoke functions from one script in another script. The first return value of the function is an integer indicating whether or not the call was successful. When it was, this integer is followed by the return values of the invoked function.
Parameters
functionName The name of the function that will be executed
arguments An arbitrary list of arguments that will be given to the invoked function
Returns
Returns at least 1 value indicating if the call succeeded:
0 The call was
successful. In
this case, the return values of the script are returned in addition to the call result,
following the call result
1 The call failed because the entity with the specified
index
does not exist or has no Scripts component
2 The call failed because it came from
another
sector than the entity is in
3 The call failed because the given script was not
found in
the entity
4 The call failed because the given function was not found in the
script
5 The call failed because the script's state has errors and is invalid
function var isCollectable(Entity
entity)
function bool isInDockingArea(Entity
other)
function var isInsideShield(vec3
point)
function bool, var isJumpRouteValid(int
fromX, int fromY, int toX, int toY)
function var isManned()
function var isTurretAllowed(TurretTemplate
ScriptTurretTemplate)
Tests if the maximum number of turrets of this kind is not reached
Parameters
function int jumpPossible(int x, int y)
Tests if the entity can jump to the specified coordinates
Parameters
y The y-coordinates of the target sector
Returns
Returns an error code:
-1 The entity doesn't have a hyperspace drive.
0 The
entity
can jump.
1 The hyperspace drive needs to recharge.
2 The target sector is
too far
away.
3 The entity is facing the wrong direction.
4 The hyperspace drive is
being
jammed.
function var moveBy(vec3 delta)
Teleports entity by vector
Returns
nothing
function int registerCallback(string
callbackName, string functionName)
Register a callback in the entity. The callback receiver has to be inside the same sector for the registration to succeed. The callback will be removed if either the entity or the receiver leaves the sector or gets destroyed. 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
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 registerDamage(Uuid
shooterId, double damage, DamageSource DamageSource)
Registers artificial damage as if the entity was damaged by the shooter
Parameters
damage The amount of damage inflicted
DamageSource The kind of source for the damage
Returns
nothing
function var removeBonus(int key)
Deletes bonus
Parameters
Returns
nothing
function var removeCargo(var good, int amount)
Removes cargo from the entity. When given a TradingGood, an exact check for that good will be performed. When given a string, only a name check will be performed, and which cargo will be removed first is undefined if there are multiple goods with the same name. An example would be Energy Cells vs. Stolen Energy Cells. The 'name' property is the same, but the 'stolen' property is different.
Parameters
amount The amount of cargo that should be removed. If this is more than there is on the ship, all specified cargo will be removed.
Returns
nothing
function var removeCrew(int number, CrewMan crewman)
function var removeScript(var script)
Returns
nothing
function var removeScriptBonuses()
Deletes all bonuses added by the current script
Returns
nothing
function var resolveScriptPath(string
path)
function bool sendCallback()
function var setAccumulatingBlockHealth(bool
bool)
If AccumulatingBlockHealth is true, a block needs to take as much damage as would be necessary to destroy all its children before it itself is destroyed. If it is set to false, the entity's blocks will have only their own durability. Set it to false if you want your entity to easily break apart, e.g. for wreckages.
Parameters
Returns
nothing
function var setAimedPosition(int
seat, vec3 in)
Returns
nothing
function var setAttachedBlockIndex(int in)
Returns
nothing
function var setCaptain(Captain [or
nil]
captain)
Returns
nothing
function var setDamageTypeMultiplier(DamageType type, float factor)
Returns
nothing
function var setDropsAttachedTurrets(bool
bool)
Sets the entities' ability to drop its attached turrets. If set to true (default) the ship has a chance to drop a turret that's attached to it when it's destroyed. This is only enabled for NPC entities.
Parameters
Returns
nothing
function var setDropsLoot(bool bool)
Sets the entities' ability to drop normal loot. Affects dropping of money, resources, cargo, turrets and upgrades. 'Loot' component is not affected by this.
Parameters
Returns
nothing
function var setMalusFactor(float
in, int reason)
Returns
nothing
function var setManned(bool in)
Returns
nothing
function var setMovePlan(BlockPlan
plan)
Set the new plan of the entity. The entity will get deleted if the plan is empty. This moves all the data out of the plan that is used as the first argument. The content of the plan given as argument is then undefined, but still valid. It might be empty, it might contain the previous plan. This operation is independent of the size of the plan, use it when you have to set large plans with lots of blocks.
Parameters
Returns
nothing
function var setPlan(BlockPlan plan)
Set the new plan of the entity. The entity will get deleted if the plan is empty. This copies the entire plan that is given as argument, keep that in mind when setting plans with large block counts.
Parameters
Returns
nothing
function var setTitle(string title, string_pair... arguments)
Sets the title that can be used as title in menus
Parameters
arguments Set the string arguments (if format string is used) as vector of string_pair.
Returns
nothing
function var setTitleArguments(string_pair... arguments)
Sets the arguments to a title
Parameters
Returns
nothing
function var setTurretSize(float
in)
Returns
nothing
function var setTurretTurningSpeed(float
in)
Returns
nothing
function var setValue(string key, var value)
Sets a custom value
Parameters
value The value to save. Must be bool, number, string or nil. If nil is given, the value will be deleted.
function var singleFlyToLocationTick(vec3
location)
Tells the ship to fly to given location, directly and without pathfinding.
Parameters
Returns
nothing
function int unregisterCallback(string callbackName, string functionName)
function var updateProductionCatchingUp(float float)
Simulates production catching up. This is used when ships return from the background simulation. Updates fighter production, academy and cloning.
Parameters
Returns
nothing
function var waitUntilAsyncWorkFinished(var
time)
Returns
nothing
function bool, var isJumpRouteValid(int
fromX, int fromY, int toX, int toY)
Checks if a hyperspace route would be valid.
Parameters
fromY Y coordinate of the origin
toX X coordinate of the destination
toY Y coordinate of the destination
Returns
Returns a bool (true, false), and, if false, a string containing the reason why it's invalid
function var block(float time)
Blocks the hyperspace engine for a certain time. While the hyperspace engine is blocked, it can't jump. For safety reasons, the hyperspace engine can only be blocked for a limited amount of time. You should only block it for a few seconds and then reblock it. Also sets the "clear space" property to false.
Parameters
Returns
nothing
function var distort(float time)
Distorts the hyperspace engine for a certain time. While the hyperspace engine is distorted, it takes 4x as long to recharge. For safety reasons, the hyperspace engine can only be distorted for a limited amount of time. You should only distort it for a few seconds and then redistort it. Also sets the "clear space" property to false.
Parameters
Returns
nothing
function var exhaust()
Exhausts the hyperspace engine as if when a jump happens.
Returns
nothing
function int... getJumpErrors(int
x, int y)
Checks if a jump to a sector would be possible and returns all errors.
Parameters
y Y coordinate of the destination
Returns
a set of JumpError codes containing the reasons why the jump is not possible
function bool, var isJumpRouteValid(int
fromX, int fromY, int toX, int toY)
Checks if a hyperspace route would be valid.
Parameters
fromY Y coordinate of the origin
toX X coordinate of the destination
toY Y coordinate of the destination
Returns
Returns a bool (true, false), and, if false, a string containing the reason why it's invalid
function var jump(int x, int y)
Initiates a hyperspace jump. This is what happens when the player presses space. This will always do the jump, no matter what.
Parameters
y Y coordinate of the destination
Returns
nothing
function int jumpPossible(int x, int y)
Checks if a jump to a sector would be possible.
Parameters
y Y coordinate of the destination
Returns
a JumpError code containing the reason why the jump is not possible
function int tryJump(int x, int y)
Tries to initiate a hyperspace jump. This is what happens when the player presses space. On failure, this will return a JumpError code with the reason.
Parameters
y Y coordinate of the destination
Returns
a JumpError code containing the reason why the jump failed
function table<TradingGood, int> findCargos(string name)
Finds all cargos with the given name.
Parameters
Returns
A map containing all matching goods, with the good as key and amount as value.
function TradingGood, int... getCargo(unsigned
int n)
function table<TradingGood, int> getCargos()
function int getNumCargos(var name)
Counts all goods of the given type. When given a string, it will match the 'name' property of the goods. When given a TradingGood it will match the exact good.
Parameters
Returns
The number of goods
function string getSummary(var goods)
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
function vec3 getAimedPositionByWeaponGroup(int groupIndex)
Returns the aimed position of the seat that controls the given weapon group.
Parameters
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
function int getControlActionsByWeaponGroup(int groupIndex)
Returns the bitset of control actions of the seat that controls the given weapon group.
Parameters
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
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
function uuid getSelectedObjectId(int
seatIndex)
Returns the id of the selected object of a given seat.
Parameters
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
function bool mayControlSquad(int
playerIndex, int squadIndex)
Checks if the given player has the right to control the given fighter squad.
Parameters
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
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
function var add(CargoBay other)
Returns
nothing
function unsigned int addCargo(TradingGood good, int amount)
Adds cargo to the entity. If the amount specified exceeds the maximum capacity of the cargo bay, as much cargo as still fits in will be added.
Parameters
amount The amount of cargo that should be added.
Returns
How much was actually added (can be less than amount when cargo bay is full)
function var clear()
Returns
nothing
function var destroyCargo(float volume)
Destroys cargo. The destruction distribution is generally equal over all goods.
Parameters
Returns
nothing
function table<TradingGood, int> findCargos(string name)
Finds all cargos with the given name.
Parameters
Returns
A map containing all matching goods, with the good as key and amount as value.
function TradingGood, int... getCargo(unsigned int n)
function table<TradingGood, int> getCargos()
function int getNumCargos(var name)
Counts all goods of the given type. When given a string, it will match the 'name' property of the goods. When given a TradingGood it will match the exact good.
Parameters
Returns
The number of goods
function string getSummary(var goods)
function var removeCargo(var good, int amount)
Removes cargo from the entity. When given a TradingGood, an exact check for that good will be performed. When given a string, only a name check will be performed, and which cargo will be removed first is undefined if there are multiple goods with the same name. An example would be Energy Cells vs. Stolen Energy Cells. The 'name' property is the same, but the 'stolen' property is different.
Parameters
amount The amount of cargo that should be removed. If this is more than there is on the ship, all specified cargo will be removed.
Returns
nothing
function int... getBlocksByBox(Box
box)
function int... getBlocksByOrientedBox(Box
box, Matrix boxOrientation)
function int... getBlocksByRay(Ray
ray, float t0,
float t1)
function int... getBlocksBySphere(Sphere
sphere)
function var, vec3 intersectRay(Ray
ray, float t0,
float t1)
function bool intersectsBox(Box box, var exceptionIndex)
function bool intersectsSphere(Sphere
sphere, var exceptionIndex)
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
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
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
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
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
function vec3 getAimedPositionByWeaponGroup(int groupIndex)
Returns the aimed position of the seat that controls the given weapon group.
Parameters
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
function int getControlActionsByWeaponGroup(int groupIndex)
Returns the bitset of control actions of the seat that controls the given weapon group.
Parameters
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
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
function uuid getSelectedObjectId(int
seatIndex)
Returns the id of the selected object of a given seat.
Parameters
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
function bool mayControlSquad(int
playerIndex, int squadIndex)
Checks if the given player has the right to control the given fighter squad.
Parameters
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
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
function var removeSeat(int seatIndex)
Removes the given seat. Seat 0 can't be removed.
Parameters
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
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
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
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
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
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
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
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
function bool dock(Entity dockee, var dockIndex)
Docks an Entity (dockee) to this Entity (parent), if the given dock is free. Note: This function doesn't dock the entity immediately, but during the upcoming update tick. If during the same tick another parent wants to dock the same dockee, the result which of the parents will actually dock the dockee is random. The dockee must be in position to be docked, otherwise this won't work.
Parameters
dockIndex The index of the dock that is to be used. Use nil to use the first free dock.
Returns
true if the given dock is free (or a free dock was found), false otherwise.
function bool forceDock(Entity dockee, var dockIndex, var blockIndex, var look, var up)
Docks an Entity (dockee) to this Entity (parent), if the given dock is free. Note: This function doesn't dock the entity immediately, but during the upcoming update tick. If during the same tick another parent wants to dock the same dockee, the result which of the parents will actually dock the dockee is random.
Parameters
dockIndex The index of the dock that is to be used. Use nil to use the first free dock.
blockIndex The index of the block on the other ship that is to be docked. If nil, uses the outermost block on the side that will be docked.
look The look direction of the object to dock. If nil, will use the parent's direction. This direction must be in local space of the parent object. You can either use a vec3, an ivec3, or a string indicating the direction, such as "x" or "-y".
up The up direction of the object to dock. If nil, will use the parent's direction. This direction must be in local space of the parent object. You can either use a vec3, an ivec3, or a string indicating the direction, such as "x" or "-y".
Returns
true if the given dock is free (or a free dock was found), false otherwise.
function Uuid... getDockedEntities()
function table_t getDocks()
function bool isDocked(var entity)
Checks if another entity is physically docked.
Parameters
Returns
true if physically docked, false otherwise.
function bool undock(Entity dockee)
Undocks an Entity (dockee) from this Entity (parent), if docked. Note: This function doesn't undock the entity immediately, but during the upcoming update tick.
Parameters
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.2 e97532556063