naev 0.11.5
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.
 
static int outfitL_get (lua_State *L)
 Gets a outfit.
 
static int outfitL_getAll (lua_State *L)
 Gets all the outfits.
 
static int outfitL_name (lua_State *L)
 Gets the translated name of the outfit.
 
static int outfitL_nameRaw (lua_State *L)
 Gets the raw (untranslated) name of the outfit.
 
static int outfitL_shortname (lua_State *L)
 Gets the translated short name of the outfit.
 
static int outfitL_type (lua_State *L)
 Gets the type of an outfit.
 
static int outfitL_typeBroad (lua_State *L)
 Gets the broad type of an outfit.
 
static int outfitL_cpu (lua_State *L)
 Gets the cpu usage of an outfit.
 
static int outfitL_mass (lua_State *L)
 Gets the mass of an outfit.
 
static int outfitL_heatFor (lua_State *L)
 Calculates a heat value to be used with heat up.
 
static int outfitL_slot (lua_State *L)
 Gets the slot name, size and property of an outfit.
 
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.
 
static int outfitL_icon (lua_State *L)
 Gets the store icon for an outfit.
 
static int outfitL_price (lua_State *L)
 Gets the price of an outfit.
 
static int outfitL_description (lua_State *L)
 Gets the description of an outfit (translated).
 
static int outfitL_summary (lua_State *L)
 Gets the summary of an outfit (translated).
 
static int outfitL_unique (lua_State *L)
 Gets whether or not an outfit is unique.
 
static int outfitL_friendlyfire (lua_State *L)
 Gets whether or not a weapon outfit can do friendly fire.
 
static int outfitL_pointdefense (lua_State *L)
 Gets whether or not a weapon outfit is point defense.
 
static int outfitL_miss_ships (lua_State *L)
 Gets whether or not a weapon outfit misses ships.
 
static int outfitL_miss_asteroids (lua_State *L)
 Gets whether or not a weapon outfit misses asteroids.
 
static int outfitL_toggleable (lua_State *L)
 Gets whether or not an outfit is toggleable.
 
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.
 
static int outfitL_weapStats (lua_State *L)
 Computes statistics for weapons.
 
static int outfitL_specificStats (lua_State *L)
 Returns raw data specific to each outfit type.
 
static int outfitL_illegality (lua_State *L)
 Gets the factions to which the outfit is illegal to.
 
static int outfitL_tags (lua_State *L)
 Gets the outfit tags.
 
int nlua_loadOutfit (nlua_env env)
 Loads the outfit library.
 
const Outfitlua_tooutfit (lua_State *L, int ind)
 Lua bindings to interact with outfits.
 
const OutfitluaL_checkoutfit (lua_State *L, int ind)
 Gets outfit at index or raises error if there is no outfit at index.
 
const OutfitluaL_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.
 
int lua_isoutfit (lua_State *L, int ind)
 Checks to see if ind is a outfit.
 
static int getprop (lua_State *L, int prop)
 

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 748 of file nlua_outfit.c.

◆ SETFIELDB

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

Definition at line 754 of file nlua_outfit.c.

◆ SETFIELDI

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

Definition at line 751 of file nlua_outfit.c.

Function Documentation

◆ getprop()

static int getprop ( lua_State * L,
int prop )
static

Definition at line 521 of file nlua_outfit.c.

◆ 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 189 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 174 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 124 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 135 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 149 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 97 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 361 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: outfit|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 489 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 215 of file nlua_outfit.c.

◆ outfitL_friendlyfire()

static int outfitL_friendlyfire ( lua_State * L)
static

Gets whether or not a weapon outfit can do friendly fire.

Lua function parameter: outfit|String o Outfit to get the property of of. Lua return parameter: boolean Whether or not the outfit can do friendly fire damage.

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

Lua function: friendlyfire

Definition at line 549 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 236 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 249 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 613 of file nlua_outfit.c.

◆ outfitL_heatFor()

static int outfitL_heatFor ( lua_State * L)
static

Calculates a heat value to be used with heat up.

Note
Outfits need mass to be able to heat up, with no mass they will fail to heat up.

Lua function parameter: Number heatup How many "pulses" are needed to heat up to 800 kelvin. Each pulse can represent a discrete event or per second if multiplied by dt. Lua return parameter: Number The heat value corresponding to the number of pulses.

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

Lua function: heatFor

Definition at line 393 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 456 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 870 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 437 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 377 of file nlua_outfit.c.

◆ outfitL_miss_asteroids()

static int outfitL_miss_asteroids ( lua_State * L)
static

Gets whether or not a weapon outfit misses asteroids.

Lua function parameter: outfit|String o Outfit to get the property of of. Lua return parameter: boolean Whether or not the outfit misses asteroids.

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

Lua function: missAsteroids

Definition at line 585 of file nlua_outfit.c.

◆ outfitL_miss_ships()

static int outfitL_miss_ships ( lua_State * L)
static

Gets whether or not a weapon outfit misses ships.

Lua function parameter: outfit|String o Outfit to get the property of of. Lua return parameter: boolean Whether or not the outfit misses ships.

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

Lua function: missShips

Definition at line 573 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 = o:name() – Equivalent to _(o: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 273 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 = o: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 293 of file nlua_outfit.c.

◆ outfitL_pointdefense()

static int outfitL_pointdefense ( lua_State * L)
static

Gets whether or not a weapon outfit is point defense.

Lua function parameter: outfit|String o Outfit to get the property of of. Lua return parameter: boolean Whether or not the outfit is point defense.

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

Lua function: pointdefense

Definition at line 561 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: outfit|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 472 of file nlua_outfit.c.

◆ outfitL_shortname()

static int outfitL_shortname ( lua_State * L)
static

Gets the translated short name of the outfit.

This translated name should be used when you have abbreviate the outfit greatly, e.g., the GUI. In the case the outfit has no special shortname, it's equivalent to outfit.name().

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

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

Lua function: shortname

Definition at line 311 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 419 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 763 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: outfit|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 510 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 890 of file nlua_outfit.c.

◆ outfitL_toggleable()

static int outfitL_toggleable ( lua_State * L)
static

Gets whether or not an outfit is toggleable.

Lua function parameter: outfit|String o Outfit to get the property of of. Lua return parameter: boolean Whether or not the outfit is toggleable.

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

Lua function: toggleable

Definition at line 597 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 327 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 345 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: outfit|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 537 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 639 of file nlua_outfit.c.

Variable Documentation

◆ outfitL_methods

const luaL_Reg outfitL_methods[]
static

Outfit metatable methods.

Definition at line 58 of file nlua_outfit.c.