19#include "nlua_outfit.h"
118 return *((
Ship**) lua_touserdata(L,ind));
131 luaL_typerror(L, ind, SHIP_METATABLE);
147 else if (lua_isstring(L, ind))
148 s =
ship_get( lua_tostring(L, ind) );
150 luaL_typerror(L, ind, SHIP_METATABLE);
155 NLUA_ERROR(L, _(
"Ship is invalid."));
169 p = (
const Ship**) lua_newuserdata(L,
sizeof(
Ship*));
171 luaL_getmetatable(L, SHIP_METATABLE);
172 lua_setmetatable(L, -2);
186 if (lua_getmetatable(L,ind)==0)
188 lua_getfield(L, LUA_REGISTRYINDEX, SHIP_METATABLE);
191 if (lua_rawequal(L, -1, -2))
214 lua_pushboolean(L,1);
216 lua_pushboolean(L,0);
248 lua_rawseti( L, -2, i+1 );
269 lua_pushstring(L, _(s->
name));
289 lua_pushstring(L, s->
name);
355 lua_pushinteger(L, s->
points);
395 int ignore_locked = lua_toboolean(L,2);
403 for (
int i=0; i<3 ; i++) {
404 for (
int j=0; j<
array_size(outfit_arrays[i]) ; j++) {
409 if (ignore_locked && sslot->
locked)
417 lua_pushstring(L,
"id" );
418 lua_pushinteger(L, k);
422 lua_pushstring(L,
"type");
426 lua_pushstring(L,
"size");
430 lua_pushstring(L,
"property");
434 lua_pushstring(L,
"required");
435 lua_pushboolean( L, sslot->
required);
438 lua_pushstring(L,
"exclusive");
442 lua_pushstring(L,
"locked");
443 lua_pushboolean( L, sslot->
locked);
446 if (sslot->
data != NULL) {
447 lua_pushstring(L,
"outfit");
452 lua_rawseti(L, -2, k++);
472 for (
int i=0; i<3 ; i++) {
475 return &outfit_arrays[i][
id-1 ];
493 int id = luaL_checkinteger(L,2);
497 lua_pushboolean(L,0);
516 lua_pushnumber(L, s->
cpu);
582 WARN(_(
"Unable to get ship comm graphic for '%s'."), s->
name);
605 WARN(_(
"Unable to get ship target graphic for '%s'."), s->
name);
628 WARN(_(
"Unable to get ship graphic for '%s'."), s->
name);
678 const char *str = luaL_optstring(L,2,NULL);
679 int internal = lua_toboolean(L,3);
696 lua_pushstring(L,buf);
714 lua_pushstring(L,s->
tags[i]);
715 lua_pushboolean(L,1);
Provides macros to work with dynamic arrays.
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
Header file with generic functions and naev-specifics.
const Outfit * luaL_validoutfit(lua_State *L, int ind)
Makes sure the outfit is valid or raises a Lua error.
const Outfit ** lua_pushoutfit(lua_State *L, const Outfit *outfit)
Pushes a outfit on the stack.
static int shipL_tags(lua_State *L)
Gets the ship tags.
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,...
static int shipL_getShipStatDesc(lua_State *L)
Gets the ship stats description for a ship.
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_price(lua_State *L)
Gets the ship's price, with and without default outfits.
const Ship ** lua_pushship(lua_State *L, const Ship *ship)
Pushes a ship on the stack.
int nlua_loadShip(nlua_env env)
Loads the ship library.
static int shipL_class(lua_State *L)
Gets the raw (untranslated) name of the ship's class.
int lua_isship(lua_State *L, int ind)
Checks to see if ind is a ship.
static int shipL_dims(lua_State *L)
Gets the onscreen dimensions of the ship.
static int shipL_time_mod(lua_State *L)
Gets the ship's time_mod.
const Ship * luaL_validship(lua_State *L, int ind)
Makes sure the ship is valid or raises a Lua error.
const Ship * luaL_checkship(lua_State *L, int ind)
Gets ship at index or raises error if there is no ship at index.
static int shipL_eq(lua_State *L)
Checks to see if two ships are the same.
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_CPU(lua_State *L)
Gets the ship available CPU.
static int shipL_gfxComm(lua_State *L)
Gets the ship's comm graphics.
const Ship * lua_toship(lua_State *L, int ind)
Lua bindings to interact with ships.
static int shipL_baseType(lua_State *L)
Gets the raw (untranslated) name of the ship's base type.
static int shipL_nameRaw(lua_State *L)
Gets the raw (untranslated) name of the ship.
static const luaL_Reg shipL_methods[]
static int shipL_slots(lua_State *L)
Gets the amount of the ship's slots.
static int shipL_description(lua_State *L)
Gets the description of the ship (translated).
static int shipL_classDisplay(lua_State *L)
Gets the raw (untranslated) display name of the ship's class (not ship's base class).
static const ShipOutfitSlot * ship_outfitSlotFromID(const Ship *s, int id)
Gets an outfit slot from ID.
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_get(lua_State *L)
Gets a ship.
static int shipL_gfx(lua_State *L)
Gets the ship's graphics.
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_fitsSlot(lua_State *L)
Checks to see if an outfit fits a ship slot.
static int shipL_gfxTarget(lua_State *L)
Gets the ship's target graphics.
glTexture ** lua_pushtex(lua_State *L, glTexture *texture)
Pushes a texture on the stack.
glTexture * gl_dupTexture(const glTexture *texture)
Duplicates a texture.
int outfit_fitsSlot(const Outfit *o, const OutfitSlot *s)
Checks to see if an outfit fits a slot.
const char * slotName(const OutfitSlotType type)
const char * slotSize(const OutfitSlotSize o)
Gets the slot size as a string.
int ship_size(const Ship *s)
Gets the size of the ship.
const char * ship_class(const Ship *s)
Gets the ship's class name in human readable form.
const char * ship_classDisplay(const Ship *s)
Gets the ship's display class in human readable form.
credits_t ship_basePrice(const Ship *s)
Gets the ship's base price (no outfits).
credits_t ship_buyPrice(const Ship *s)
The ship buy price, includes default outfits.
const Ship * ship_getAll(void)
Gets the array (array.h) of all ships.
glTexture * ship_loadCommGFX(const Ship *s)
Loads the ship's comm graphic.
const Ship * ship_get(const char *name)
Gets a ship based on its name.
int ss_statsGetLua(lua_State *L, const ShipStats *s, const char *name, int internal)
Gets a ship stat value by name and pushes it to Lua.
int ss_statsDesc(const ShipStats *s, char *buf, int len, int newline)
Writes the ship statistics description.
const char * sp_display(unsigned int spid)
Gets the display name of a slot property (in English).
Pilot slot that can contain outfits.
A ship outfit, depends radically on the type.
ShipOutfitSlot * outfit_utility
ShipOutfitSlot * outfit_weapon
ShipOutfitSlot * outfit_structure
Abstraction for rendering sprite sheets.