Entity Callbacks

```
       callback

```

 Executed whenever the entity enters a sector.

Parameters

```
           entityIndex The index of the entity that entered the sector

           x Sector X coordinates of the entered sector

           y Sector Y coordinates of the entered sector

```

```
       callback

```

 Executed whenever two block objects collided in the sector

Parameters

```
           objectIndexA The index of the one colliding object

           objectIndexB The index of the other colliding object

```

```
       callback

```

 Executed whenever a block object is hit by a shot in the sector. This callback is executed \*before\* the damage is dealt to the object.

Parameters

```
           objectIndex The index of the object that got shot at

           shooterIndex The index of the craft that fired the shot

           location The impact location

```

```
       callback

```

### onHullHit

(objectIndex, blockIndex, shooterIndex, damage, location)

 Executed whenever a block object is hit by a shot in the sector. This callback is executed \*before\* the damage is dealt to the object. Don't delete the block that is hit by the shot, this will lead to a crash.

Parameters

```
           objectIndex The index of the object that got shot at

           blockIndex The index of the block that was hit by the shot

           shooterIndex The index of the craft that fired the shot

           damage The damage the shot dealt to the object

           location The impact location

```

```
       callback

```

### onShieldHit

(objectIndex, shooterIndex, damage, location)

 Executed whenever an object's shield is hit by a shot in the sector. This callback is executed \*before\* the damage is dealt to the object.

Parameters

```
           objectIndex The index of the object that got shot at

           shooterIndex The index of the craft that fired the shot

           damage The damage the shot dealt to the object

           location The impact location

```

```
       callback

```

### destinationSectorReady

(sectorReady)

 Executed when the availability state of the destination sector changes. When the sector is loaded into memory, it's set to true. When the sector is unloaded from memory, because there's no player near it, it's set to false.

Parameters

```
           sectorReady Boolean indicating whether the destination sector is in memory

```

```
       callback

```

### onStartDialog

(objectIndex)

 Executed when a dialog is started.

Parameters

```
           objectIndex The index of the entity the dialog is started with

```

```
       callback

```

### onCargoChanged

(objectIndex, delta, name, pluralName, price, size)

 Executed whenever the cargo of an entity in the sector changes. This callback is executed \*after\* the cargo was changed on the entity.

Parameters

```
           objectIndex The index of the entity

           delta The amount of cargo that changed

           name The name of the cargo that changed

           pluralName The plural name of the cargo that changed

           price The price of the cargo that changed

           size The size of the cargo that changed

```

```
       callback

```

### onBlockHealed

(objectIndex, blockIndex, damage)

 Executed whenever a block of the entity is healed. This callback is executed \*before\* the healing is done to the block. Don't remove the block in this callback, this will lead to a crash.

Parameters

```
           objectIndex The index of the healed object

           blockIndex The index of the healed block

           damage The damage the entity was healed for

```

```
       callback

```

### onBlockPlanChanged

(objectIndex)

 Executed whenever the plan of the entity is changed.

Parameters

```
           objectIndex The index of the entity

```

```
       callback

```

### onAllBlocksChanged

(objectIndex)

 Executed whenever the plan of the entity is changed.

Parameters

```
           objectIndex The index of the entity

```

```
       callback

```

### onBlockChanged

(objectIndex, blockIndex, changeFlags)

 Executed whenever the plan of the entity is changed.

Parameters

```
           objectIndex The index of the entity

           blockIndex The index of the block

           changeFlags The flags of the block changes

```

```
       callback

```

### onBlockDestroyed

(objectIndex, index)

 Executed whenever a block of the block object got destroyed This callback is executed \*after\* the block was destroyed

Parameters

```
           objectIndex The index of the entity

           index Index of the block

```

```
       callback

```

### onBlockDamaged

(objectIndex, blockIndex, inflictorId, damage)

 Executed whenever a block object is damaged in the sector. This callback is executed \*after\* the damage is dealt to the block, and before the block may be destroyed due to damage. Don't remove the block in this callback, this will lead to a crash.

Parameters

```
           objectIndex The index of the damaged object

           blockIndex The index of the damaged block

           inflictorId The index of the entity that inflicted the damage

           damage The damage that was inflicted to the entity

```

```
       callback

```

### onBlockRemove

(objectIndex, blockIndex)

 Executed whenever a block is removed from the plan by a player. This callback is executed **before** the block is removed.

Parameters

```
           objectIndex The index of the entity

           blockIndex The index of the block

```

```
       callback

```

### onBlockRemoved

(objectIndex, blockIndex)

 Executed whenever a block is removed from the plan by a player. This callback is executed **after** the block is removed.

Parameters

```
           objectIndex The index of the entity

           blockIndex The index of the block

```

```
       callback

```

### onBlockAdded

(objectIndex, blockIndex)

 Executed whenever a new block is added to the entity. This callback is executed after the block was added.

Parameters

```
           objectIndex The index of the entity

           blockIndex The index of the block

```

```
       callback

```

### onBreak

(objectIndex, plan...)

 Executed when the plan of the entity breaks. This callback is executed after the block broke. This callback is expensive, don't register for it if you don't absolutely need it.

Parameters

```
           objectIndex The index of the entity

           plan... The plans of the broken off parts

```

```
       callback

```

### onSystemsChanged

(shipIndex)

 Executed whenever the systems of a ship in the sector changed. This callback is executed \*after\* the system was changed on the entity.

Parameters

```
           shipIndex The index of the ship

```

```
       callback

```

### onDamaged

(objectIndex, amount, inflictor)

 Executed whenever an entity is damaged in the sector. This callback is executed \*before\* the damage is dealt.

Parameters

```
           objectIndex The index of the damaged object

           amount The amount of damage that was dealt

           inflictor The index of the entity that dealt the damage or nil

```

```
       callback

```

### onHealed

(objectIndex, amount, inflictor)

 Executed whenever an entity is healed in the sector. This callback is executed \*before\* the damage is healed.

Parameters

```
           objectIndex The index of the damaged entity

           amount The amount of damage that was healed

           inflictor The index of the entity that dealt the damage or nil

```

```
       callback

```

### onDestroyed

(index, lastDamageInflictor)

 Executed when the entity was destroyed

Parameters

```
           index The index of the entity that was destroyed

           lastDamageInflictor The index of the last entity that inflicted damage to the destroyed entity

```

```
       callback

```

### onCrewChanged

(index)

 Executed whenever the crew of the entity changes. This callback is executed \*after\* the crew was changed on the entity.

Parameters

```
           index The index of the entity

```

```
       callback

```

### onCrewChanged

(index, delta, profession)

 Executed whenever the crew of an entity in the sector changes. This callback is executed \*after\* the crew was changed on the entity.

Parameters

```
           index The index of the entity

           delta The amount of crewmen that changed

           profession The profession of the crew that changed

```

```
       callback

```

### onLootCollected

(collector, lootIndex)

 Executed whenever loot gets collected by anyone, be it player or AI faction

Parameters

```
           collector The index of the entity which collected the loot

           lootIndex The index of the collected loot

```

```
       callback

```

### onMoneyLootCollected

(collector, lootIndex, value)

 Executed whenever money loot gets collected by the entity

Parameters

```
           collector The index of the entity which collected the loot

           lootIndex The index of the collected loot

           value The amount of credits the loot contained

```

```
       callback

```

### onMaterialLootCollected

(collector, lootIndex, materialType, value)

 Executed whenever material loot gets collected by

Parameters

```
           collector The index of the entity which collected the loot

           lootIndex The index of the loot that was collected

           materialType The type of material contained in the loot

           value The amount of material the loot contained

```

```
       callback

```

### onSystemUpgradeLootCollected

(collector, lootIndex)

 Executed whenever material loot gets collected by

Parameters

```
           collector The index of the entity which collected the loot

           lootIndex The index of the loot that was collected

```

```
       callback

```

### onTurretLootCollected

(collector, lootIndex)

 Executed whenever turret loot gets collected by the entity

Parameters

```
           collector The index of the entity which collected the loot

           lootIndex The index of the collected loot

```

```
       callback

```

### onColorLootCollected

(playerIndex, lootIndex)

 Executed whenever color loot gets collected by the entity

Parameters

```
           playerIndex The index of the entity which collected the loot

           lootIndex The index of the collected loot

```

```
       callback

```

### onCargoLootCollected

(collector, lootIndex, amount, name, pluralName, description, icon, price, size, owner)

 Executed whenever trading good loot gets collected by a player

Parameters

```
           collector The index of the entity that collected loot

           lootIndex The index of the collected loot

           amount The amount of goods that were collected

           name The name of the good that was collected

           pluralName The plural name of the good that was collected

           description The description of the good that was collected

           icon The path to the icon of the good that was collected

           price The price of the good that was collected

           size The size of the good that was collected

           owner The original owner of the cargo

```

```
       callback

```

### onTurretDestroyed

(turretIndex, shipIndex)

 Executed whenever a turret of the entity was destroyed

Parameters

```
           turretIndex The index of the turret that was destroyed

           shipIndex The index of the entity that turret was attached to

```

```
       callback

```

### onShieldDamaged

(entityIndex, amount, inflictorId)

 Executed whenever the entities shield is damaged

Parameters

```
           entityIndex The index of the entity

           amount The amount of damage inflicted

           inflictorId The index of the entity that inflicted the damage, or nil if no entity caused the damage

```

```
       callback

```

### onShieldHealed

(entityIndex, amount)

 Executed whenever the entities shield is healed

Parameters

```
           entityIndex The index of the entity

           amount The amount of damage healed

```

```
       callback

```

### onShieldActivate

(entityIndex)

 Executed whenever the entities shield activates

Parameters

```
           entityIndex The index of the entity

```

```
       callback

```

### onShieldDeactivate

(entityIndex)

 Executed whenever the entities shield deactivates

Parameters

```
           entityIndex The index of the entity

```

```
       callback

```

### onShotFired

(entityIndex)

 Executed whenever the entity fires a shot

Parameters

```
           entityIndex The index of the entity

```

```
       callback

```

### onStartFiring

(entityIndex)

 Executed whenever the entity starts firing

Parameters

```
           entityIndex The index of the entity

```

```
       callback

```

### onStopFiring

(entityIndex)

 Executed whenever the entity stops firing

Parameters

```
           entityIndex The index of the entity

```