Ticking

Definition

Found in this.tick is a JavaScript function that is called 60 times per second. In this function’s body, you will be able to code specific actions that your mod needs to take automagically while the game is running. This function can be modified while the modded game is running and the changes will apply automagically.

Events

General

Your mod can receive events through the function this.event:

this.event = function(event,game) {
  switch (event.name)
  {
    case "ship_spawned":
      if (event.ship != null)
      {
        shipJustSpawned(event.ship) ;
      }
      break ;
  }
} ;

Available events

Event nameDescriptionAdditional event fields
ship_spawned*A ship just spawned in game or respawnedevent.ship
ship_destroyedA ship was just destroyedevent.ship, event.killer
alien_destroyedAn alien was just killedevent.alien, event.killer
asteroid_destroyedA movable asteroid was just destroyed (this event won’t trigger for non-movable asteroids)event.asteroid, event.killer
collectible_pickedA ship just picked a collectible itemevent.collectible, event.ship
ui_component_clickedA ship just clicked a (clickable) UI component on their screenevent.ship, event.id

Note: * means that this event only works with unspecified root_mode (root_mode: "")