Module ship_template

Functions for ship templates, including triggers

Class ShipTemplate

shiptemplate:getBaseName () returns the basename for this ship template.
shiptemplate:getShortname () returns the shotname for this ship template
shiptemplate:onCreate (callback) registers a function to run when a ship is first built or created.
shiptemplate:onDestroyed (callback) registers a function to run when a ship is destroyed.
shiptemplate:onDock (callback) registers a function to run when a ship starts docking
shiptemplate:onDocked (callback) registers a function to run when a ship finishes docking
shiptemplate:onHyper (callback) registers a function to run when a ship enters hyperspace
shiptemplate:onHyperExit (callback) registers a function to run when a ship exits hyperspace
shiptemplate:onLand (callback) registers a function to run when a ship starts landing
shiptemplate:onLanded (callback) registers a function to run when a ship finishes landing
shiptemplate:onLaunch (callback) registers a function to run when a ship starts launching
shiptemplate:onLaunched (callback) registers a function to run when a ship finishes launching
shiptemplate:onSpawned (callback) registers a function to run when a ship is placed in a system via a space spawn.
shiptemplate:onTargeted (callback) registers a function to run when a ship is targeted by another ship.
shiptemplate:onTick (callback) registers a function to run every space tick (20 seconds, when the space prompt shows).
shiptemplate:onUndock (callback) registers a function to run when a ship begins undocking
shiptemplate:onUndocked (callback) registers a function to run when a ship finishes undocking


Class ShipTemplate

Functions on ship template variables
shiptemplate:getBaseName ()
returns the basename for this ship template.

Returns:

    string the template's basename
shiptemplate:getShortname ()
returns the shotname for this ship template

Returns:

    string the template's shortname
shiptemplate:onCreate (callback)
registers a function to run when a ship is first built or created.

Parameters:

  • callback func the function to run, taking arguments: 1. the Ship being created 2. the Character who finished it. Can be nil.

Usage:

    self:onCreate(function(self)
      -- Place a mob in the ship's cockpit
      Character.invoke(12345):toRoom(self:getCockpit())
    end)
shiptemplate:onDestroyed (callback)
registers a function to run when a ship is destroyed. This function will run after the ship destruction message is shown to the system, but before any players inside the ship are dealt with. You can use it to move players off of the ship before they're killed.

Parameters:

  • callback func the function to run, taking arguments: 1. the Ship being destroyed 2. the Ship destroying it (can be nil) 3. the Character destroying it (can be nil)

Usage:

    self:onDestroyed(function(self, byShip, byChar)
      if not byChar then
        return
      end
      ch:echoAt("Good job, you destroyed the pirate!")
    end)
shiptemplate:onDock (callback)
registers a function to run when a ship starts docking

Parameters:

  • callback func the function to run, taking arguments: 1. the Ship initiating docking 2. the Ship being docked with 3. the Starsystem the ships are in

Usage:

    self:onDock(function(self, target, system)
shiptemplate:onDocked (callback)
registers a function to run when a ship finishes docking

Parameters:

  • callback func the function to run, taking arguments: 1. the Ship that initiated docking 2. the Ship it docked with 3. the Starsystem the ships are in

Usage:

    self:onDocked(function(self, target, system)
shiptemplate:onHyper (callback)
registers a function to run when a ship enters hyperspace

Parameters:

  • callback func the function to run, taking arguments: 1. the Ship entering hyperspace 2. the Starsystem just exited

Usage:

    self:onHyper(function(self, system)
shiptemplate:onHyperExit (callback)
registers a function to run when a ship exits hyperspace

Parameters:

  • callback func the function to run, taking arguments: 1. the Ship exiting hyperspace 2. the Starsystem just entered

Usage:

    self:onHyperExit(function(self, system)
shiptemplate:onLand (callback)
registers a function to run when a ship starts landing

Parameters:

  • callback func the function to run, taking arguments: 1. the Ship landing 2. the Starsystem being exited

Usage:

    self:onLand(function(self, system)
shiptemplate:onLanded (callback)
registers a function to run when a ship finishes landing

Parameters:

  • callback func the function to run, taking arguments: 1. the Ship just landed 2. the Room just landed into 3. the Starsystem just exited

Usage:

    self:onLanded(function(self, room, system)
shiptemplate:onLaunch (callback)
registers a function to run when a ship starts launching

Parameters:

  • callback func the function to run, taking arguments: 1. the Ship being launched 2. the Room being launched from

Usage:

    self:onLaunch(function(self, room)
shiptemplate:onLaunched (callback)
registers a function to run when a ship finishes launching

Parameters:

  • callback func the function to run, taking arguments: 1. the Ship just launched 2. the Room just launched from 3. the Starsystem just launched into

Usage:

    self:onLaunched(function(self, room, system)
shiptemplate:onSpawned (callback)
registers a function to run when a ship is placed in a system via a space spawn.

Parameters:

  • callback func the function to run, taking arguments: 1. the Ship being spawned

Usage:

    self:onSpawned(function(self)
      -- Place a mob in the ship's cockpit
      Character.invoke(12345):toRoom(self:getCockpit())
    end)
shiptemplate:onTargeted (callback)
registers a function to run when a ship is targeted by another ship.

Parameters:

  • callback func the function to run, taking arguments: 1. the Ship being targeted 2. the Ship targeting it

Usage:

    self:onTargeted(function(self, targeter)
      self:radio("Help! I'm being attacked by "..targeter:getName())
    end)
shiptemplate:onTick (callback)
registers a function to run every space tick (20 seconds, when the space prompt shows). Only fires for ships which are in a starsystem, not landed/in hyperspace/launching/etc

Parameters:

  • callback func the function to run, taking arguments: 1. the Ship

Usage:

    self:onTick(function(self)
      self:echoToSystem("Red lights flash on the exterior of "..self:getName())
    end)
shiptemplate:onUndock (callback)
registers a function to run when a ship begins undocking

Parameters:

  • callback func the function to run, taking arguments: 1. the Ship initiating the undocking 2. the Ship it was docked with 3. the Starsystem the ships are in

Usage:

    self:onUndock(function(self, target, system)
shiptemplate:onUndocked (callback)
registers a function to run when a ship finishes undocking

Parameters:

  • callback func the function to run, taking arguments: 1. the Ship that initiated undocking 2. the Ship it was docked with 3. the Starsystem the ships are in

Usage:

    self:onUndocked(function(self, target, system)
generated by LDoc 1.5.0 Last updated 2024-10-22 16:05:00