Sector Callbacks

callback ### onPlayerLeft

(playerIndex)

 Executed whenever a player leaves the sector.

Parameters

```
           playerIndex Index of the player

```

```
       callback

```

 Executed whenever a player enters the sector.

Parameters

```
           playerIndex Index of the player

```

```
       callback

```

 Executed whenever a new entity is created in the sector

Parameters

```
           entityIndex The index of the new entity

```

```
       callback

```

 Executed whenever a new shot is created in the sector

Parameters

```
           shotIndex The index of the new shot

```

```
       callback

```

 Executed whenever a entity enters the sector.

Parameters

```
           shipIndex The index of the entity that entered the 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

```

### 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 an object is healed in the sector. 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 a plan of an entity is changed in the sector.

Parameters

```
           objectIndex The index of the entity

```

```
       callback

```

### onAllBlocksChanged

(objectIndex)

 Executed whenever a plan of an entity is changed in the sector.

Parameters

```
           objectIndex The index of the entity

```

```
       callback

```

### onBlockChanged

(objectIndex, blockIndex, changeFlags)

 Executed whenever a plan of an entity is changed in the sector.

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 a 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

```

### 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 whenever an entity with durability was destroyed in the sector

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 a entity in the sector 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 an 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 an entity

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 an entity

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 an entity controlled by AI

Parameters

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

           lootIndex The index of the collected loot

```

```
       callback

```

### onColorLootCollected

(collector, lootIndex)

 Executed whenever color loot gets collected by a AI controlled entity

Parameters

```
           collector 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 was destroyed in the sector

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 a shield is damaged in the sector

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 a shield is healed in the sector

Parameters

```
           entityIndex The index of the entity

           amount The amount of damage healed

```

```
       callback

```

### onShieldActivate

(entityIndex)

 Executed whenever a shield activates in the sector

Parameters

```
           entityIndex The index of the entity

```

```
       callback

```

### onShieldDeactivate

(entityIndex)

 Executed whenever a shield deactivates in the sector

Parameters

```
           entityIndex The index of the entity

```

```
       callback

```

### onShotFired

(entityIndex)

 Executed whenever a shot is fired in the sector

Parameters

```
           entityIndex The index of the firing entity

```

```
       callback

```

### onStartFiring

(entityIndex)

 Executed whenever an entity starts firing in the sector

Parameters

```
           entityIndex The index of the firing entity

```

```
       callback

```

### onStopFiring

(entityIndex)

 Executed whenever an entity stops firing in the sector

Parameters

```
           entityIndex The index of the firing entity

```