naev 0.10.4
Macros | Functions | Variables
nlua_outfit.c File Reference

Handles the Lua outfit bindings. More...

#include "nlua_outfit.h"
#include "array.h"
#include "log.h"
#include "damagetype.h"
#include "nlua_faction.h"
#include "nlua_pilot.h"
#include "nlua_ship.h"
#include "nlua_tex.h"
#include "nluadef.h"
#include "player.h"
#include "rng.h"
#include "slots.h"

Go to the source code of this file.

Macros

#define SETFIELD(name, value)
 
#define SETFIELDI(name, value)
 
#define SETFIELDB(name, value)
 

Functions

static int outfitL_eq (lua_State *L)
 Checks to see if two outfits are the same. More...
 
static int outfitL_get (lua_State *L)
 Gets a outfit. More...
 
static int outfitL_getAll (lua_State *L)
 Gets all the outfits. More...
 
static int outfitL_name (lua_State *L)
 Gets the translated name of the outfit. More...
 
static int outfitL_nameRaw (lua_State *L)
 Gets the raw (untranslated) name of the outfit. More...
 
static int outfitL_type (lua_State *L)
 Gets the type of an outfit. More...
 
static int outfitL_typeBroad (lua_State *L)
 Gets the broad type of an outfit. More...
 
static int outfitL_cpu (lua_State *L)
 Gets the cpu usage of an outfit. More...
 
static int outfitL_mass (lua_State *L)
 Gets the mass of an outfit. More...
 
static int outfitL_slot (lua_State *L)
 Gets the slot name, size and property of an outfit. More...
 
static int outfitL_limit (lua_State *L)
 Gets the limit string of the outfit. Only one outfit can be equipped at the same time for each limit string. More...
 
static int outfitL_icon (lua_State *L)
 Gets the store icon for an outfit. More...
 
static int outfitL_price (lua_State *L)
 Gets the price of an outfit. More...
 
static int outfitL_description (lua_State *L)
 Gets the description of an outfit (translated). More...
 
static int outfitL_summary (lua_State *L)
 Gets the summary of an outfit (translated). More...
 
static int outfitL_unique (lua_State *L)
 Gets whether or not an outfit is unique. More...
 
static int outfitL_getShipStat (lua_State *L)
 Gets a shipstat from an Outfit by name, or a table containing all the ship stats if not specified. More...
 
static int outfitL_weapStats (lua_State *L)
 Computes statistics for weapons. More...
 
static int outfitL_specificStats (lua_State *L)
 Returns raw data specific to each outfit type. More...
 
static int outfitL_illegality (lua_State *L)
 Gets the factions to which the outfit is illegal to. More...
 
static int outfitL_tags (lua_State *L)
 Gets the outfit tags. More...
 
int nlua_loadOutfit (nlua_env env)
 Loads the outfit library. More...
 
const Outfitlua_tooutfit (lua_State *L, int ind)
 Lua bindings to interact with outfits. More...
 
const OutfitluaL_checkoutfit (lua_State *L, int ind)
 Gets outfit at index or raises error if there is no outfit at index. More...
 
const OutfitluaL_validoutfit (lua_State *L, int ind)
 Makes sure the outfit is valid or raises a Lua error. More...
 
const Outfit ** lua_pushoutfit (lua_State *L, const Outfit *outfit)
 Pushes a outfit on the stack. More...
 
int lua_isoutfit (lua_State *L, int ind)
 Checks to see if ind is a outfit. More...
 

Variables

static const luaL_Reg outfitL_methods []
 

Detailed Description

Handles the Lua outfit bindings.

Definition in file nlua_outfit.c.

Macro Definition Documentation

◆ SETFIELD

#define SETFIELD (   name,
  value 
)
Value:
lua_pushnumber( L, value ); \
lua_setfield( L, -2, name )

Definition at line 627 of file nlua_outfit.c.

◆ SETFIELDB

#define SETFIELDB (   name,
  value 
)
Value:
lua_pushboolean( L, value ); \
lua_setfield( L, -2, name )

Definition at line 633 of file nlua_outfit.c.

◆ SETFIELDI

#define SETFIELDI (   name,
  value 
)
Value:
lua_pushinteger( L, value ); \
lua_setfield( L, -2, name )

Definition at line 630 of file nlua_outfit.c.

Function Documentation

◆ lua_isoutfit()

int lua_isoutfit ( lua_State *  L,
int  ind 
)

Checks to see if ind is a outfit.

Parameters
LLua state to check.
indIndex position to check.
Returns
1 if ind is a outfit.

Definition at line 175 of file nlua_outfit.c.

◆ lua_pushoutfit()

const Outfit ** lua_pushoutfit ( lua_State *  L,
const Outfit outfit 
)

Pushes a outfit on the stack.

Parameters
LLua state to push outfit into.
outfitOutfit to push.
Returns
Newly pushed outfit.

Definition at line 160 of file nlua_outfit.c.

◆ lua_tooutfit()

const Outfit * lua_tooutfit ( lua_State *  L,
int  ind 
)

Lua bindings to interact with outfits.

This will allow you to create and manipulate outfits in-game.

An example would be:

o = outfit.get( "Heavy Laser" ) -- Gets the outfit by name
cpu_usage = o:cpu() -- Gets the cpu usage of the outfit
slot_name, slot_size = o:slot() -- Gets slot information about the outfit

Lua module: outfit

Gets outfit at index.

Parameters
LLua state to get outfit from.
indIndex position to find the outfit.
Returns
Outfit found at the index in the state.

Definition at line 110 of file nlua_outfit.c.

◆ luaL_checkoutfit()

const Outfit * luaL_checkoutfit ( lua_State *  L,
int  ind 
)

Gets outfit at index or raises error if there is no outfit at index.

Parameters
LLua state to get outfit from.
indIndex position to find outfit.
Returns
Outfit found at the index in the state.

Definition at line 121 of file nlua_outfit.c.

◆ luaL_validoutfit()

const Outfit * luaL_validoutfit ( lua_State *  L,
int  ind 
)

Makes sure the outfit is valid or raises a Lua error.

Parameters
LState currently running.
indIndex of the outfit to validate.
Returns
The outfit (doesn't return if fails - raises Lua error ).

Definition at line 135 of file nlua_outfit.c.

◆ nlua_loadOutfit()

int nlua_loadOutfit ( nlua_env  env)

Loads the outfit library.

Parameters
envEnvironment to load outfit library into.
Returns
0 on success.

Definition at line 83 of file nlua_outfit.c.

◆ outfitL_cpu()

static int outfitL_cpu ( lua_State *  L)
static

Gets the cpu usage of an outfit.

Lua usage parameter: print( o:cpu() ) – Prints the cpu usage of an outfit

Lua function parameter: Outfit o Outfit to get information of. Lua return parameter: string The amount of cpu the outfit uses.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: cpu

Definition at line 329 of file nlua_outfit.c.

◆ outfitL_description()

static int outfitL_description ( lua_State *  L)
static

Gets the description of an outfit (translated).

Lua usage parameter: description = o:description()

Lua function parameter: String o Outfit to get the description of. Lua function parameter:[opt=player.pilot()] Pilot p Pilot to set description to. Lua return parameter: string The description (with translating).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: description

Definition at line 435 of file nlua_outfit.c.

◆ outfitL_eq()

static int outfitL_eq ( lua_State *  L)
static

Checks to see if two outfits are the same.

Lua usage parameter: if o1 == o2 then – Checks to see if outfit o1 and o2 are the same

Lua function parameter: Outfit o1 First outfit to compare. Lua function parameter: Outfit o2 Second outfit to compare. Lua return parameter: boolean true if both outfits are the same.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: __eq

Definition at line 201 of file nlua_outfit.c.

◆ outfitL_get()

static int outfitL_get ( lua_State *  L)
static

Gets a outfit.

Lua usage parameter: s = outfit.get( "Heavy Laser" ) – Gets the heavy laser

Lua function parameter: string s Raw (untranslated) name of the outfit to get. Lua return parameter: Outfit|nil The outfit matching name or nil if error.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: get

Definition at line 222 of file nlua_outfit.c.

◆ outfitL_getAll()

static int outfitL_getAll ( lua_State *  L)
static

Gets all the outfits.

Lua return parameter: Table Table containing all the outfits.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: getAll

Definition at line 235 of file nlua_outfit.c.

◆ outfitL_getShipStat()

static int outfitL_getShipStat ( lua_State *  L)
static

Gets a shipstat from an Outfit by name, or a table containing all the ship stats if not specified.

Lua function parameter: Outfit o Outfit 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: Value of the ship stat or a tale containing all the ship stats if name is not specified.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: shipstat

Definition at line 492 of file nlua_outfit.c.

◆ outfitL_icon()

static int outfitL_icon ( lua_State *  L)
static

Gets the store icon for an outfit.

Lua usage parameter: ico = o:icon() – Gets the shop icon for an outfit

Lua function parameter: Outfit o Outfit to get information of. Lua return parameter: Tex The texture containing the icon of the outfit.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: icon

Definition at line 402 of file nlua_outfit.c.

◆ outfitL_illegality()

static int outfitL_illegality ( lua_State *  L)
static

Gets the factions to which the outfit is illegal to.

Lua function parameter: o Outfit to get illegality status of. Lua return parameter: table Table of all the factions the outfit is illegal to.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: illegality

Definition at line 749 of file nlua_outfit.c.

◆ outfitL_limit()

static int outfitL_limit ( lua_State *  L)
static

Gets the limit string of the outfit. Only one outfit can be equipped at the same time for each limit string.

Lua function parameter: Outfit o Outfit to get information of. Lua return parameter: string|nil Limit string or nil if not applicable.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: limit

Definition at line 383 of file nlua_outfit.c.

◆ outfitL_mass()

static int outfitL_mass ( lua_State *  L)
static

Gets the mass of an outfit.

Lua usage parameter: print( o:mass() ) – Prints the mass of an outfit

Lua function parameter: Outfit o Outfit to get information of. Lua return parameter: string The amount of mass the outfit uses.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: mass

Definition at line 345 of file nlua_outfit.c.

◆ outfitL_name()

static int outfitL_name ( lua_State *  L)
static

Gets the translated name of the outfit.

This translated name should be used for display purposes (e.g. messages). It cannot be used as an identifier for the outfit; for that, use outfit.nameRaw() instead.

Lua usage parameter: outfitname = s:name() – Equivalent to _(s:nameRaw())

Lua function parameter: Outfit s Outfit to get the translated name of. Lua return parameter: string The translated name of the outfit.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: name

Definition at line 259 of file nlua_outfit.c.

◆ outfitL_nameRaw()

static int outfitL_nameRaw ( lua_State *  L)
static

Gets the raw (untranslated) name of the outfit.

This untranslated name should be used for identification purposes (e.g. can be passed to outfit.get()). It should not be used directly for display purposes without manually translating it with _().

Lua usage parameter: outfitrawname = s:nameRaw()

Lua function parameter: Outfit s Outfit to get the raw name of. Lua return parameter: string The raw name of the outfit.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: nameRaw

Definition at line 279 of file nlua_outfit.c.

◆ outfitL_price()

static int outfitL_price ( lua_State *  L)
static

Gets the price of an outfit.

Lua usage parameter: price = o:price()

Lua function parameter: String o Outfit to get the price of. Lua return parameter: number The price, in credits.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: price

Definition at line 418 of file nlua_outfit.c.

◆ outfitL_slot()

static int outfitL_slot ( lua_State *  L)
static

Gets the slot name, size and property of an outfit.

Lua usage parameter: slot_name, slot_size, slot_prop = o:slot() – Gets an outfit's slot info

Lua function parameter: Outfit o Outfit to get information of. Lua return parameter: string Human readable name (in English). Lua return parameter: string Human readable size (in English). Lua return parameter: string Human readable property (in English). Lua return parameter: boolean Slot is required. Lua return parameter: boolean Slot is exclusive.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: slot

Definition at line 365 of file nlua_outfit.c.

◆ outfitL_specificStats()

static int outfitL_specificStats ( lua_State *  L)
static

Returns raw data specific to each outfit type.

Lua return parameter: A table containing the raw values.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: specificstats

Definition at line 642 of file nlua_outfit.c.

◆ outfitL_summary()

static int outfitL_summary ( lua_State *  L)
static

Gets the summary of an outfit (translated).

Lua usage parameter: summary = o:summary()

Lua function parameter: String o Outfit to get the summary of. Lua function parameter:[opt=player.pilot()] Pilot p Pilot to set summary to. Lua function parameter:[opt=false] string noname Whether or not to hide the outfit name at the top. Lua return parameter: string The summary (with translating).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: summary

Definition at line 456 of file nlua_outfit.c.

◆ outfitL_tags()

static int outfitL_tags ( lua_State *  L)
static

Gets the outfit tags.

Lua usage parameter: if o:tags["fancy"] then – Has "fancy" tag

Lua function parameter: Outfit o Outfit to get tags of. Lua return parameter: table Table of tags where the name is the key and true is the value.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: tags

Definition at line 769 of file nlua_outfit.c.

◆ outfitL_type()

static int outfitL_type ( lua_State *  L)
static

Gets the type of an outfit.

Lua usage parameter: print( o:type() ) – Prints the type of the outfit

Lua function parameter: Outfit o Outfit to get information of. Lua return parameter: string The name of the outfit type (in English).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: type

Definition at line 295 of file nlua_outfit.c.

◆ outfitL_typeBroad()

static int outfitL_typeBroad ( lua_State *  L)
static

Gets the broad type of an outfit.

This name is more generic and vague than type().

Lua usage parameter: print( o:typeBroad() ) – Prints the broad type of the outfit

Lua function parameter: Outfit o Outfit to get information of. Lua return parameter: string The name of the outfit broad type (in English).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: typeBroad

Definition at line 313 of file nlua_outfit.c.

◆ outfitL_unique()

static int outfitL_unique ( lua_State *  L)
static

Gets whether or not an outfit is unique.

Lua usage parameter: isunique = o:unique()

Lua function parameter: String o Outfit to get the uniqueness of. Lua return parameter: boolean The uniqueness of the outfit.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: unique

Definition at line 476 of file nlua_outfit.c.

◆ outfitL_weapStats()

static int outfitL_weapStats ( lua_State *  L)
static

Computes statistics for weapons.

Lua function parameter: Outfit o Outfit to compute for. Lua function parameter:[opt=nil] Pilot p Pilot to use ship stats when computing. Lua return parameter: number Damage per secondof the outfit. Lua return parameter: number Disable per second of the outfit. Lua return parameter: number Energy per second of the outfit. Lua return parameter: number Range of the outfit. Lua return parameter: number trackmin Minimum tracking value of the outfit. Lua return parameter: number trackmax Maximum tracking value of the outfit. Lua return parameter: number lockon Time to lockon.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: weapstats

Definition at line 518 of file nlua_outfit.c.

Variable Documentation

◆ outfitL_methods

const luaL_Reg outfitL_methods[]
static
Initial value:
= {
{ "__tostring", outfitL_name },
{ "__eq", outfitL_eq },
{ "get", outfitL_get },
{ "getAll", outfitL_getAll },
{ "name", outfitL_name },
{ "nameRaw", outfitL_nameRaw },
{ "type", outfitL_type },
{ "typeBroad", outfitL_typeBroad },
{ "cpu", outfitL_cpu },
{ "mass", outfitL_mass },
{ "slot", outfitL_slot },
{ "limit", outfitL_limit },
{ "icon", outfitL_icon },
{ "price", outfitL_price },
{ "description", outfitL_description },
{ "summary", outfitL_summary },
{ "unique", outfitL_unique },
{ "shipstat", outfitL_getShipStat },
{ "weapstats", outfitL_weapStats },
{ "specificstats", outfitL_specificStats },
{ "illegality", outfitL_illegality },
{ "tags", outfitL_tags },
{0,0}
}
static int outfitL_limit(lua_State *L)
Gets the limit string of the outfit. Only one outfit can be equipped at the same time for each limit ...
Definition: nlua_outfit.c:383
static int outfitL_mass(lua_State *L)
Gets the mass of an outfit.
Definition: nlua_outfit.c:345
static int outfitL_illegality(lua_State *L)
Gets the factions to which the outfit is illegal to.
Definition: nlua_outfit.c:749
static int outfitL_cpu(lua_State *L)
Gets the cpu usage of an outfit.
Definition: nlua_outfit.c:329
static int outfitL_slot(lua_State *L)
Gets the slot name, size and property of an outfit.
Definition: nlua_outfit.c:365
static int outfitL_tags(lua_State *L)
Gets the outfit tags.
Definition: nlua_outfit.c:769
static int outfitL_typeBroad(lua_State *L)
Gets the broad type of an outfit.
Definition: nlua_outfit.c:313
static int outfitL_specificStats(lua_State *L)
Returns raw data specific to each outfit type.
Definition: nlua_outfit.c:642
static int outfitL_summary(lua_State *L)
Gets the summary of an outfit (translated).
Definition: nlua_outfit.c:456
static int outfitL_type(lua_State *L)
Gets the type of an outfit.
Definition: nlua_outfit.c:295
static int outfitL_icon(lua_State *L)
Gets the store icon for an outfit.
Definition: nlua_outfit.c:402
static int outfitL_getShipStat(lua_State *L)
Gets a shipstat from an Outfit by name, or a table containing all the ship stats if not specified.
Definition: nlua_outfit.c:492
static int outfitL_getAll(lua_State *L)
Gets all the outfits.
Definition: nlua_outfit.c:235
static int outfitL_nameRaw(lua_State *L)
Gets the raw (untranslated) name of the outfit.
Definition: nlua_outfit.c:279
static int outfitL_get(lua_State *L)
Gets a outfit.
Definition: nlua_outfit.c:222
static int outfitL_description(lua_State *L)
Gets the description of an outfit (translated).
Definition: nlua_outfit.c:435
static int outfitL_name(lua_State *L)
Gets the translated name of the outfit.
Definition: nlua_outfit.c:259
static int outfitL_weapStats(lua_State *L)
Computes statistics for weapons.
Definition: nlua_outfit.c:518
static int outfitL_price(lua_State *L)
Gets the price of an outfit.
Definition: nlua_outfit.c:418
static int outfitL_eq(lua_State *L)
Checks to see if two outfits are the same.
Definition: nlua_outfit.c:201
static int outfitL_unique(lua_State *L)
Gets whether or not an outfit is unique.
Definition: nlua_outfit.c:476

Outfit metatable methods.

Definition at line 51 of file nlua_outfit.c.