![]() |
naev 0.11.5
|
Handles the Lua ship bindings. More...
#include "nlua_ship.h"#include "array.h"#include "log.h"#include "nlua_outfit.h"#include "nlua_tex.h"#include "nluadef.h"#include "rng.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_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_getPoints (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_gfxComm (lua_State *L) |
| Gets the ship's comm graphics. | |
| static int | shipL_gfxTarget (lua_State *L) |
| Gets the ship's target 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_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_tags (lua_State *L) |
| Gets the ship tags. | |
| 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 182 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 166 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 116 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 127 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 141 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 90 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 465 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 304 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 320 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 336 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 513 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 659 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 642 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 208 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 490 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 229 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 242 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 352 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 675 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 691 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 559 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 391 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 623 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 return parameter: Tex The comm graphics of the ship.
| L | Lua State |
Lua function: gfxComm
Definition at line 577 of file nlua_ship.c.
|
static |
Gets the ship's target graphics.
Will not work without access to the Tex module.
Lua usage parameter: gfx = s:gfxTarget()
Lua function parameter: Ship s Ship to get target graphics of. Lua return parameter: Tex The target graphics of the ship.
| L | Lua State |
Lua function: gfxTarget
Definition at line 600 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 266 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 286 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 530 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 370 of file nlua_ship.c.
|
static |
Gets the ship tags.
Lua usage parameter: if s:tags()["fancy"] then – Has "fancy" tag
Lua function parameter: Ship s Ship to get tags of. Lua return parameter: table Table of tags where the name is the key and true is the value.
| L | Lua State |
Lua function: tags
Definition at line 709 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 545 of file nlua_ship.c.
|
static |
Ship metatable methods.
Definition at line 55 of file nlua_ship.c.