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. |
inherits (s) | Gets the ship it inherits stats from if applicable. |
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). |
faction (s) | Gets the faction of a ship. |
fabricator (s) | Gets the raw (untranslated) fabricator of the ship. |
crew (s) | Gets the number of crew of the ship. |
mass (s) | Gets the number of mass of the ship. |
armour (s) | Gets the number of armour of the ship. |
cargo (s) | Gets the number of cargo of the ship. |
fuelConsumption (s) | Gets the number of fuel consumption of the ship. |
license (s) | Gets license required for the ship. |
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. |
size (s) | Gets the path where the ship's graphics are located. |
gfxComm (s[, resolution=512]) | 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[, tag=nil]) | Gets the ship tags. |
render (s, dir, engineglow, tilt) | Renders the pilot to a canvas |
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()
- inherits (s)
-
Gets the ship it inherits stats from if applicable.
Parameters:
- s Ship Ship to get the ship it is inheriting from.
Returns:
-
Ship or nil
The ship it is inheritng from or nil if not
applicable.
- 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()
- faction (s)
-
Gets the faction of a ship.
Parameters:
- s Ship Ship to get faction of.
Returns:
-
Faction
The faction of the ship, or nil if not applicable.
Usage:
shipclass = s:faction()
- fabricator (s)
-
Gets the raw (untranslated) fabricator of the ship.
Parameters:
- s Ship Ship to get fabricator of.
Returns:
-
string
The raw name of the ship's fabricator.
- crew (s)
-
Gets the number of crew of the ship.
Parameters:
- s Ship Ship to get crew of.
Returns:
-
integer
The number of crew the ship has.
- mass (s)
-
Gets the number of mass of the ship.
Parameters:
- s Ship Ship to get mass of.
Returns:
-
integer
The number of mass the ship has.
- armour (s)
-
Gets the number of armour of the ship.
Parameters:
- s Ship Ship to get armour of.
Returns:
-
integer
The number of armour the ship has.
- cargo (s)
-
Gets the number of cargo of the ship.
Parameters:
- s Ship Ship to get cargo of.
Returns:
-
integer
The number of cargo the ship has.
- fuelConsumption (s)
-
Gets the number of fuel consumption of the ship.
Parameters:
- s Ship Ship to get fuel consumption of.
Returns:
-
integer
The number of fuel consumption of the ship.
- license (s)
-
Gets license required for the ship.
Parameters:
- s Ship Ship to get license of.
Returns:
-
string
Required license or nil if not necessary.
Usage:
license = s:license()
- 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:
- number Number of weapon slots.
- number Number of utility slots.
- 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:
- number The ship's final purchase price.
- 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.
- size (s)
-
Gets the path where the ship's graphics are located. Useful for seeing
if two ships share the same graphics.
Parameters:
- s Ship Ship to get the path of the graphis of.
Returns:
-
string
The path to the ship graphics.
- gfxComm (s[, resolution=512])
-
Gets the ship's comm graphics.
Will not work without access to the Tex module.
Parameters:
- s Ship Ship to get comm graphics of.
- resolution number Resolution to render the image at. (default 512)
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:
- number Width of the ship.
- 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[, tag=nil])
-
Gets the ship tags.
Parameters:
- s Ship Ship to get tags of.
- tag string Tag to check if exists. (default nil)
Returns:
-
table or boolean
Table of tags where the name is the key and true
is the value or a boolean value if a string is passed as the second parameter
indicating whether or not the specified tag exists.
Usage:
if s:tags()["fancy"] then -- Has the "fancy" tag
if s:tags("fancy") then -- Has the "fancy" tag
- render (s, dir, engineglow, tilt)
-
Renders the pilot to a canvas
Parameters:
- s Ship Ship to render on the screen.
- dir number Direction the ship should be facing (in radians).
- engineglow number How much engine glow to render with.
- tilt number How much to tilt the ship (in radians).
Returns:
-
Canvas
The canvas with the pilot drawn on it.