![]() |
naev 0.12.6
|
Handles the Lua ship bindings. More...
#include "nlua_ship.h"#include "array.h"#include "nlua_canvas.h"#include "nlua_faction.h"#include "nlua_outfit.h"#include "nlua_tex.h"#include "nluadef.h"#include "player.h"#include "slots.h"
Go to the source code of this file.
Functions | |
| static const ShipOutfitSlot * | ship_outfitSlotFromID (const Ship *s, int id) |
| Gets an outfit slot from ID. | |
| static int | shipL_eq (lua_State *L) |
| Checks to see if two ships are the same. | |
| static int | shipL_get (lua_State *L) |
| Gets a ship. | |
| static int | shipL_getAll (lua_State *L) |
| Gets a table containing all the ships. | |
| static int | shipL_name (lua_State *L) |
| Gets the translated name of the ship. | |
| static int | shipL_nameRaw (lua_State *L) |
| Gets the raw (untranslated) name of the ship. | |
| static int | shipL_baseType (lua_State *L) |
| Gets the raw (untranslated) name of the ship's base type. | |
| static int | shipL_inherits (lua_State *L) |
| Gets the ship it inherits stats from if applicable. | |
| static int | shipL_class (lua_State *L) |
| Gets the raw (untranslated) name of the ship's class. | |
| static int | shipL_classDisplay (lua_State *L) |
| Gets the raw (untranslated) display name of the ship's class (not ship's base class). | |
| static int | shipL_faction (lua_State *L) |
| Gets the faction of a ship. | |
| static int | shipL_fabricator (lua_State *L) |
| Gets the raw (untranslated) fabricator of the ship. | |
| static int | shipL_crew (lua_State *L) |
| Gets the number of crew of the ship. | |
| static int | shipL_mass (lua_State *L) |
| Gets the number of mass of the ship. | |
| static int | shipL_armour (lua_State *L) |
| Gets the number of armour of the ship. | |
| static int | shipL_cargo (lua_State *L) |
| Gets the number of cargo of the ship. | |
| static int | shipL_fuelConsumption (lua_State *L) |
| Gets the number of fuel consumption of the ship. | |
| static int | shipL_license (lua_State *L) |
| Gets license required for the ship. | |
| static int | shipL_points (lua_State *L) |
| Gets the point value of a ship. Used for comparing relative ship strengths (minus outfits). | |
| static int | shipL_slots (lua_State *L) |
| Gets the amount of the ship's slots. | |
| static int | shipL_getSlots (lua_State *L) |
| Get a table of slots of a ship, where a slot is a table with a string size, type, and property. | |
| static int | shipL_fitsSlot (lua_State *L) |
| Checks to see if an outfit fits a ship slot. | |
| static int | shipL_CPU (lua_State *L) |
| Gets the ship available CPU. | |
| static int | shipL_gfxPath (lua_State *L) |
| Gets the path where the ship's graphics are located. Useful for seeing if two ships share the same graphics. | |
| static int | shipL_gfxComm (lua_State *L) |
| Gets the ship's comm graphics. | |
| static int | shipL_gfxStore (lua_State *L) |
| Gets the ship's store graphics. | |
| static int | shipL_gfx (lua_State *L) |
| Gets the ship's graphics. | |
| static int | shipL_dims (lua_State *L) |
| Gets the onscreen dimensions of the ship. | |
| static int | shipL_screenSize (lua_State *L) |
| Gets the onscreen size of the ship. | |
| static int | shipL_price (lua_State *L) |
| Gets the ship's price, with and without default outfits. | |
| static int | shipL_time_mod (lua_State *L) |
| Gets the ship's time_mod. | |
| static int | shipL_getSize (lua_State *L) |
| 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. | |
| static int | shipL_description (lua_State *L) |
| Gets the description of the ship (translated). | |
| static int | shipL_getShipStat (lua_State *L) |
| Gets a shipstat from an Ship by name, or a table containing all the ship stats if not specified. | |
| static int | shipL_getShipStatDesc (lua_State *L) |
| Gets the ship stats description for a ship. | |
| static int | shipL_known (lua_State *L) |
| Gets whether or not the ship is known to the player, as in they know a spob that sells it or own it. | |
| static int | shipL_tags (lua_State *L) |
| Gets the ship tags. | |
| static int | shipL_render (lua_State *L) |
| Renders the pilot to a canvas. | |
| int | nlua_loadShip (nlua_env env) |
| Loads the ship library. | |
| const Ship * | lua_toship (lua_State *L, int ind) |
| Lua bindings to interact with ships. | |
| const Ship * | luaL_checkship (lua_State *L, int ind) |
| Gets ship at index or raises error if there is no ship at index. | |
| const Ship * | luaL_validship (lua_State *L, int ind) |
| Makes sure the ship is valid or raises a Lua error. | |
| const Ship ** | lua_pushship (lua_State *L, const Ship *ship) |
| Pushes a ship on the stack. | |
| int | lua_isship (lua_State *L, int ind) |
| Checks to see if ind is a ship. | |
Variables | |
| static const luaL_Reg | shipL_methods [] |
Handles the Lua ship bindings.
Definition in file nlua_ship.c.
| int lua_isship | ( | lua_State * | L, |
| int | ind ) |
Checks to see if ind is a ship.
| L | Lua state to check. |
| ind | Index position to check. |
Definition at line 209 of file nlua_ship.c.
Pushes a ship on the stack.
| L | Lua state to push ship into. |
| ship | Ship to push. |
Definition at line 193 of file nlua_ship.c.
| const Ship * lua_toship | ( | lua_State * | L, |
| int | ind ) |
Lua bindings to interact with ships.
This will allow you to create and manipulate ships in-game.
An example would be:
Lua module: ship
Gets ship at index.
| L | Lua state to get ship from. |
| ind | Index position to find the ship. |
Definition at line 143 of file nlua_ship.c.
| const Ship * luaL_checkship | ( | lua_State * | L, |
| int | ind ) |
Gets ship at index or raises error if there is no ship at index.
| L | Lua state to get ship from. |
| ind | Index position to find ship. |
Definition at line 154 of file nlua_ship.c.
| const Ship * luaL_validship | ( | lua_State * | L, |
| int | ind ) |
Makes sure the ship is valid or raises a Lua error.
| L | State currently running. |
| ind | Index of the ship to validate. |
Definition at line 168 of file nlua_ship.c.
| int nlua_loadShip | ( | nlua_env | env | ) |
Loads the ship library.
| env | Environment to load ship library into. |
Definition at line 117 of file nlua_ship.c.
|
static |
Gets an outfit slot from ID.
| s | Ship to get slot of. |
| id | ID to get slot of. |
Definition at line 639 of file nlua_ship.c.
|
static |
Gets the number of armour of the ship.
Lua function parameter: Ship s Ship to get armour of. Lua return parameter: integer The number of armour the ship has.
| L | Lua State |
Lua function: armour
Definition at line 457 of file nlua_ship.c.
|
static |
Gets the raw (untranslated) name of the ship's base type.
For example "Empire Lancelot" and "Lancelot" are both of the base type "Lancelot".
Lua usage parameter: type = s:baseType()
Lua function parameter: Ship s Ship to get the ship base type of. Lua return parameter: string The raw name of the ship base type.
| L | Lua State |
Lua function: baseType
Definition at line 332 of file nlua_ship.c.
|
static |
Gets the number of cargo of the ship.
Lua function parameter: Ship s Ship to get cargo of. Lua return parameter: integer The number of cargo the ship has.
| L | Lua State |
Lua function: cargo
Definition at line 471 of file nlua_ship.c.
|
static |
Gets the raw (untranslated) name of the ship's class.
Lua usage parameter: shipclass = s:class()
Lua function parameter: Ship s Ship to get ship class name of. Lua return parameter: string The raw name of the ship's class.
| L | Lua State |
Lua function: class
Definition at line 365 of file nlua_ship.c.
|
static |
Gets the raw (untranslated) display name of the ship's class (not ship's base class).
Lua usage parameter: shipclass = s:classDisplay()
Lua function parameter: Ship s Ship to get ship display class name of. Lua return parameter: string The raw name of the ship's display class.
| L | Lua State |
Lua function: classDisplay
Definition at line 382 of file nlua_ship.c.
|
static |
Gets the ship available CPU.
Lua usage parameter: cpu_left = s:cpu()
Lua function parameter: Ship s Ship to get available CPU of. Lua return parameter: number The CPU available on the ship.
| L | Lua State |
Lua function: cpu
Definition at line 685 of file nlua_ship.c.
|
static |
Gets the number of crew of the ship.
Lua function parameter: Ship s Ship to get crew of. Lua return parameter: integer The number of crew the ship has.
| L | Lua State |
Lua function: crew
Definition at line 429 of file nlua_ship.c.
|
static |
Gets the description of the ship (translated).
Lua usage parameter: description = s:description()
Lua function parameter: Ship s Ship to get the description of. Lua return parameter: string The description of the ship.
| L | Lua State |
Lua function: description
Definition at line 865 of file nlua_ship.c.
|
static |
Gets the onscreen dimensions of the ship.
Lua return parameter: number Width of the ship. Lua return parameter: number Height of the ship.
| L | Lua State |
Lua function: dims
Definition at line 835 of file nlua_ship.c.
|
static |
Checks to see if two ships are the same.
Lua usage parameter: if s1 == s2 then – Checks to see if ship s1 and s2 are the same
Lua function parameter: Ship s1 First ship to compare. Lua function parameter: Ship s2 Second ship to compare. Lua return parameter: boolean true if both ships are the same.
| L | Lua State |
Lua function: __eq
Definition at line 235 of file nlua_ship.c.
|
static |
Gets the raw (untranslated) fabricator of the ship.
Lua function parameter: Ship s Ship to get fabricator of. Lua return parameter: string The raw name of the ship's fabricator.
| L | Lua State |
Lua function: fabricator
Definition at line 415 of file nlua_ship.c.
|
static |
Gets the faction of a ship.
Lua usage parameter: shipclass = s:faction()
Lua function parameter: Ship s Ship to get faction of. Lua return parameter: Faction The faction of the ship, or nil if not applicable.
| L | Lua State |
Lua function: faction
Definition at line 398 of file nlua_ship.c.
|
static |
Checks to see if an outfit fits a ship slot.
Lua function parameter: Ship s Ship to check. Lua function parameter: number id ID of the slot to check (index in getSlots table). Lua function parameter: Outfit o Outfit to check to see if it fits in the slot. Lua return parameter: boolean WHether or not the outfit fits the slot.
| L | Lua State |
Lua function: fitsSlot
Definition at line 662 of file nlua_ship.c.
|
static |
Gets the number of fuel consumption of the ship.
Lua function parameter: Ship s Ship to get fuel consumption of. Lua return parameter: integer The number of fuel consumption of the ship.
| L | Lua State |
Lua function: fuelConsumption
Definition at line 485 of file nlua_ship.c.
|
static |
Gets a ship.
Lua usage parameter: s = ship.get( "Hyena" ) – Gets the hyena
Lua function parameter: string s Raw (untranslated) name of the ship to get. Lua return parameter: Ship The ship matching name or nil if error.
| L | Lua State |
Lua function: get
Definition at line 256 of file nlua_ship.c.
|
static |
Gets a table containing all the ships.
Lua return parameter: table A table containing all the ships in the game.
| L | Lua State |
Lua function: getAll
Definition at line 269 of file nlua_ship.c.
|
static |
Gets a shipstat from an Ship by name, or a table containing all the ship stats if not specified.
Lua function parameter: Ship s Ship to get ship stat of. Lua function parameter:[opt=nil] string name Name of the ship stat to get. Lua function parameter:[opt=false] boolean internal Whether or not to use the internal representation. Lua return parameter: number|table Value of the ship stat or a tale containing all the ship stats if name is not specified.
| L | Lua State |
Lua function: shipstat
Definition at line 884 of file nlua_ship.c.
|
static |
Gets the ship stats description for a ship.
Lua function parameter: Ship s Ship to get ship stat description of. Lua return parameter: string Description of the ship's stats.
| L | Lua State |
Lua function: shipstatDesc
Definition at line 900 of file nlua_ship.c.
|
static |
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.
Lua function parameter: Ship s Ship to get the size of. Lua return parameter: number The ship's size.
| L | Lua State |
Lua function: size
Definition at line 732 of file nlua_ship.c.
|
static |
Get a table of slots of a ship, where a slot is a table with a string size, type, and property.
Lua usage parameter: for i, v in ipairs( ship.getSlots( ship.get("Llama") ) ) do print(v["type"]) end
Lua function parameter: Ship s Ship to get slots of Lua function parameter:[opt=false] boolean ignore_locked Whether or not to ignore locked slots. Lua return parameter: A table of tables with slot properties string "size", string "type", string "property", boolean "required", boolean "exclusive", boolean "locked", and (if applicable) outfit "outfit" (Strings are English.)
| L | Lua State |
Lua function: getSlots
Definition at line 563 of file nlua_ship.c.
|
static |
Gets the ship's graphics.
Will not work without access to the Tex module. These are nearly always a sprite sheet.
Lua usage parameter: gfx = s:gfx()
Lua function parameter: Ship s Ship to get graphics of. Lua return parameter: Tex The graphics of the ship.
| L | Lua State |
Lua function: gfx
Definition at line 815 of file nlua_ship.c.
|
static |
Gets the ship's comm graphics.
Will not work without access to the Tex module.
Lua usage parameter: gfx = s:gfxComm()
Lua function parameter: Ship s Ship to get comm graphics of. Lua function parameter:[opt=512] number resolution Resolution to render the image at. Lua return parameter: Tex The comm graphics of the ship.
| L | Lua State |
Lua function: gfxComm
Definition at line 766 of file nlua_ship.c.
|
static |
Gets the path where the ship's graphics are located. Useful for seeing if two ships share the same graphics.
Lua function parameter: Ship s Ship to get the path of the graphis of. Lua return parameter: string The path to the ship graphics.
| L | Lua State |
Lua function: size
Definition at line 747 of file nlua_ship.c.
|
static |
Gets the ship's store graphics.
Will not work without access to the Tex module.
Lua usage parameter: gfx = s:gfxStore()
Lua function parameter: Ship s Ship to get store graphics of. Lua return parameter: Tex The store graphics of the ship.
| L | Lua State |
Lua function: gfxStore
Definition at line 790 of file nlua_ship.c.
|
static |
Gets the ship it inherits stats from if applicable.
Lua function parameter: Ship s Ship to get the ship it is inheriting from. Lua return parameter: Ship|nil The ship it is inheritng from or nil if not applicable.
| L | Lua State |
Lua function: inherits
Definition at line 347 of file nlua_ship.c.
|
static |
Gets whether or not the ship is known to the player, as in they know a spob that sells it or own it.
Definition at line 913 of file nlua_ship.c.
|
static |
Gets license required for the ship.
Lua usage parameter: license = s:license()
Lua function parameter: Ship s Ship to get license of. Lua return parameter: string Required license or nil if not necessary.
| L | Lua State |
Lua function: license
Definition at line 501 of file nlua_ship.c.
|
static |
Gets the number of mass of the ship.
Lua function parameter: Ship s Ship to get mass of. Lua return parameter: integer The number of mass the ship has.
| L | Lua State |
Lua function: mass
Definition at line 443 of file nlua_ship.c.
|
static |
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.
Lua usage parameter: shipname = s:name() – Equivalent to _(s:nameRaw())
Lua function parameter: Ship s Ship to get the translated name of. Lua return parameter: string The translated name of the ship.
| L | Lua State |
Lua function: name
Definition at line 293 of file nlua_ship.c.
|
static |
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 _().
Lua usage parameter: shipname = s:nameRaw()
Lua function parameter: Ship s Ship to get the raw name of. Lua return parameter: string The raw name of the ship.
| L | Lua State |
Lua function: nameRaw
Definition at line 313 of file nlua_ship.c.
|
static |
Gets the point value of a ship. Used for comparing relative ship strengths (minus outfits).
Lua usage parameter: points = s:points()
Lua function parameter: Ship s Ship to get points of. Lua return parameter: number Point value of the ship.
| L | Lua State |
Lua function: points
Definition at line 520 of file nlua_ship.c.
|
static |
Gets the ship's price, with and without default outfits.
Lua usage parameter: price, base = s:price()
Lua function parameter: Ship s Ship to get the price of. Lua return parameter: number The ship's final purchase price. Lua return parameter: number The ship's base price.
| L | Lua State |
Lua function: price
Definition at line 702 of file nlua_ship.c.
|
static |
Renders the pilot to a canvas.
Lua function parameter: Ship s Ship to render on the screen. Lua function parameter: number dir Direction the ship should be facing (in radians). Lua function parameter: number engineglow How much engine glow to render with. Lua function parameter: number tilt How much to tilt the ship (in radians). Lua return parameter: Canvas The canvas with the pilot drawn on it.
| L | Lua State |
Lua function: render
Definition at line 970 of file nlua_ship.c.
|
static |
Gets the onscreen size of the ship.
Lua return parameter: number Size of the ship.
| L | Lua State |
Lua function: screenSize
Definition at line 849 of file nlua_ship.c.
|
static |
Gets the amount of the ship's slots.
Lua usage parameter: slots_weapon, slots_utility, slots_structure = p:slots()
Lua function parameter: Ship s Ship to get ship slots of. Lua return parameter: number Number of weapon slots. Lua return parameter: number Number of utility slots. Lua return parameter: number Number of structure slots.
| L | Lua State |
Lua function: slots
Definition at line 538 of file nlua_ship.c.
|
static |
Gets the ship tags.
Lua usage parameter: if s:tags()["fancy"] then – Has the "fancy" tag Lua usage parameter: if s:tags("fancy") then – Has the "fancy" tag
Lua function parameter: Ship s Ship to get tags of. Lua function parameter:[opt=nil] string tag Tag to check if exists. Lua return parameter: table|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.
| L | Lua State |
Lua function: tags
Definition at line 954 of file nlua_ship.c.
|
static |
Gets the ship's time_mod.
Lua function parameter: Ship s Ship to get the time_mod of. Lua return parameter: number The ship's time_mod.
| L | Lua State |
Lua function: time_mod
Definition at line 717 of file nlua_ship.c.
|
static |
Ship metatable methods.
Definition at line 70 of file nlua_ship.c.