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.
getAll () Gets a table containing all the ships.
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.
classDisplay (s) Gets the raw (untranslated) display name of the ship's class (not ship's base class).
points (s) Gets the point value of a ship.
slots (s) Gets the amount of the ship's slots.
getSlots (s[, ignore_locked=false]) Get a table of slots of a ship, where a slot is a table with a string size, type, and property
fitsSlot (s, id, o) Checks to see if an outfit fits a ship slot.
cpu (s) Gets the ship available CPU.
price (s) Gets the ship's price, with and without default outfits.
time_mod (s) Gets the ship's time_mod.
size (s) Gets the ship's size.
gfxComm (s) Gets the ship's comm graphics.
gfxStore (s) Gets the ship's store graphics.
gfx (s) Gets the ship's graphics.
dims () Gets the onscreen dimensions of the ship.
screenSize () Gets the onscreen size of the ship.
description (s) Gets the description of the ship (translated).
shipstat (s[, name=nil[, internal=false]]) Gets a shipstat from an Ship by name, or a table containing all the ship stats if not specified.
shipstatDesc (s) Gets the ship stats description for a ship.
tags (s) Gets the ship tags.


Functions

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

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.

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
    
getAll ()
Gets a table containing all the ships.

Returns:

    table A table containing all the ships in the game.
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.

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 _().

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".

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.

Parameters:

  • s Ship Ship to get ship class name of.

Returns:

    string The raw name of the ship's class.

Usage:

    shipclass = s:class()
    
classDisplay (s)
Gets the raw (untranslated) display name of the ship's class (not ship's base class).

Parameters:

  • s Ship Ship to get ship display class name of.

Returns:

    string The raw name of the ship's display class.

Usage:

    shipclass = s:classDisplay()
    
points (s)
Gets the point value of a ship. Used for comparing relative ship strengths (minus outfits).

Parameters:

  • s Ship Ship to get points of.

Returns:

    number Point value of the ship.

Usage:

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

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[, ignore_locked=false])
Get a table of slots of a ship, where a slot is a table with a string size, type, and property "type", string "property", boolean "required", boolean "exclusive", boolean "locked", and (if applicable) outfit "outfit" (Strings are English.)

Parameters:

  • s Ship Ship to get slots of
  • ignore_locked boolean Whether or not to ignore locked slots. (default false)

Returns:

    A table of tables with slot properties string "size", string

Usage:

    for i, v in ipairs( ship.getSlots( ship.get("Llama") ) ) do
    print(v["type"]) end
    
fitsSlot (s, id, o)
Checks to see if an outfit fits a ship slot.

Parameters:

  • s Ship Ship to check.
  • id number ID of the slot to check (index in getSlots table).
  • o Outfit Outfit to check to see if it fits in the slot.

Returns:

    boolean WHether or not the outfit fits the slot.
cpu (s)
Gets the ship available CPU.

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.

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()
    
time_mod (s)
Gets the ship's time_mod.

Parameters:

  • s Ship Ship to get the time_mod of.

Returns:

    number The ship's time_mod.
size (s)
Gets the ship's size. Ultra-light is 1, light is 2, medium is 3, heavy-medium is 4, heavy is 5, and super-heavy is 6.

Parameters:

  • s Ship Ship to get the size of.

Returns:

    number The ship's size.
gfxComm (s)
Gets the ship's comm graphics.

Will not work without access to the Tex module.

Parameters:

  • s Ship Ship to get comm graphics of.

Returns:

    Tex The comm graphics of the ship.

Usage:

    gfx = s:gfxComm()
    
gfxStore (s)
Gets the ship's store graphics.

Will not work without access to the Tex module.

Parameters:

  • s Ship Ship to get store graphics of.

Returns:

    Tex The store graphics of the ship.

Usage:

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

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

Parameters:

  • s Ship Ship to get graphics of.

Returns:

    Tex The graphics of the ship.

Usage:

    gfx = s:gfx()
    
dims ()
Gets the onscreen dimensions of the ship.

Returns:

  1. number Width of the ship.
  2. number Height of the ship.
screenSize ()
Gets the onscreen size of the ship.

Returns:

    number Size of the ship.
description (s)
Gets the description of the ship (translated).

Parameters:

  • s Ship Ship to get the description of.

Returns:

    string The description of the ship.

Usage:

    description = s:description()
    
shipstat (s[, name=nil[, internal=false]])
Gets a shipstat from an Ship by name, or a table containing all the ship stats if not specified.

Parameters:

  • s Ship Ship to get ship stat of.
  • name string Name of the ship stat to get. (default nil)
  • internal boolean Whether or not to use the internal representation. (default false)

Returns:

    number or table Value of the ship stat or a tale containing all the ship stats if name is not specified.
shipstatDesc (s)
Gets the ship stats description for a ship.

Parameters:

  • s Ship Ship to get ship stat description of.

Returns:

    string Description of the ship's stats.
tags (s)
Gets the ship tags.

Parameters:

  • s Ship Ship to get tags of.

Returns:

    table Table of tags where the name is the key and true is the value.

Usage:

    if s:tags()["fancy"] then -- Has "fancy" tag
    
generated by LDoc 1.5.0 Last updated 2024-03-28 09:18:05