Naev

Module ship

Lua bindings to interact with ships.

This will allow you to create and manipulate ships in-game.

An example would be:

 s = ship.get( "Empire Lancelot" ) -- Gets the ship
 cpu_free = s:cpu() -- Gets the CPU
 

Functions

__eq (s1, s2) Checks to see if two ships are the same.
get (s) Gets a ship.
name (s) Gets the translated name of the ship.
nameRaw (s) Gets the raw (untranslated) name of the ship.
baseType (s) Gets the raw (untranslated) name of the ship's base type.
class (s) Gets the raw (untranslated) name of the ship's class.
slots (s) Gets the amount of the ship's slots.
getSlots (s) Get a table of slots of a ship, where a slot is a table with a string size, type, and property
cpu (s) Gets the ship available CPU.
price (s) Gets the ship's price, with and without default outfits.
gfxTarget (s) Gets the ship's target graphics.
gfx (s) Gets the ship's graphics.


Functions

__eq (s1, s2)
Checks to see if two ships are the same. ( s1, s2 )

Parameters:

  • s1 Ship First ship to compare.
  • s2 Ship Second ship to compare.

Returns:

    boolean true if both ships are the same.

Usage:

    if s1 == s2 then -- Checks to see if ship s1 and s2 are the same
get (s)
Gets a ship. ( s )

Parameters:

  • s string Raw (untranslated) name of the ship to get.

Returns:

    Ship The ship matching name or nil if error.

Usage:

    s = ship.get( "Hyena" ) -- Gets the hyena
name (s)
Gets the translated name of the ship.

This translated name should be used for display purposes (e.g. messages). It cannot be used as an identifier for the ship; for that, use ship.nameRaw() instead. ( s )

Parameters:

  • s Ship Ship to get the translated name of.

Returns:

    string The translated name of the ship.

Usage:

    shipname = s:name() -- Equivalent to `_(s:nameRaw())`
nameRaw (s)
Gets the raw (untranslated) name of the ship.

This untranslated name should be used for identification purposes (e.g. can be passed to ship.get()). It should not be used directly for display purposes without manually translating it with _(). ( s )

Parameters:

  • s Ship Ship to get the raw name of.

Returns:

    string The raw name of the ship.

Usage:

    shipname = s:nameRaw()
baseType (s)
Gets the raw (untranslated) name of the ship's base type.

For example "Empire Lancelot" and "Lancelot" are both of the base type "Lancelot". ( s )

Parameters:

  • s Ship Ship to get the ship base type of.

Returns:

    string The raw name of the ship base type.

Usage:

    type = s:baseType()
class (s)
Gets the raw (untranslated) name of the ship's class. ( s )

Parameters:

  • s Ship Ship to get ship class name of.

Returns:

    string The raw name of the ship's class.

Usage:

    shipclass = s:class()
slots (s)
Gets the amount of the ship's slots. ( s )

Parameters:

  • s Ship Ship to get ship slots of.

Returns:

  1. number Number of weapon slots.
  2. number Number of utility slots.
  3. number Number of structure slots.

Usage:

    slots_weapon, slots_utility, slots_structure = p:slots()
getSlots (s)
Get a table of slots of a ship, where a slot is a table with a string size, type, and property (Strings are English.)( s )

Parameters:

  • s Ship to get slots of

Returns:

    A table of tables with slot properties string "size", string "type", and string "property".

Usage:

    for i, v in ipairs( ship.getSlots( ship.get("Llama") ) ) do print(v["type"]) end
cpu (s)
Gets the ship available CPU. ( s )

Parameters:

  • s Ship Ship to get available CPU of.

Returns:

    number The CPU available on the ship.

Usage:

    cpu_left = s:cpu()
price (s)
Gets the ship's price, with and without default outfits. ( s )

Parameters:

  • s Ship Ship to get the price of.

Returns:

  1. number The ship's final purchase price.
  2. number The ship's base price.

Usage:

    price, base = s:price()
gfxTarget (s)
Gets the ship's target graphics.

Will not work without access to the Tex module. ( s )

Parameters:

  • s Ship Ship to get target graphics of.

Returns:

    Tex The target graphics of the ship.

Usage:

    gfx = s:gfxTarget()
gfx (s)
Gets the ship's graphics.

Will not work without access to the Tex module. These are nearly always a sprite sheet. ( s )

Parameters:

  • s Ship Ship to get graphics of.

Returns:

    Tex The graphics of the ship.

Usage:

    gfx = s:gfx()
generated by LDoc 1.4.6 Last updated 2020-11-29 21:27:05