naev 0.12.6
nlua_outfit.c File Reference

Handles the Lua outfit bindings. More...

#include "nlua_outfit.h"
#include "array.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 "slots.h"
Include dependency graph for nlua_outfit.c:

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_exists (lua_State *L)
 Gets a outfit if it exists, nil otherwise.
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_known (lua_State *L)
 Gets whether or not the outfit is known to the player, as in they know a spob that sells it or own it.
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 798 of file nlua_outfit.c.

◆ SETFIELDB

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

Definition at line 804 of file nlua_outfit.c.

◆ SETFIELDI

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

Definition at line 801 of file nlua_outfit.c.

Function Documentation

◆ getprop()

int getprop ( lua_State * L,
int prop )
static

Definition at line 566 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 191 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 176 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 126 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 137 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 151 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 99 of file nlua_outfit.c.

◆ outfitL_cpu()

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

◆ outfitL_description()

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

◆ outfitL_eq()

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

◆ outfitL_exists()

int outfitL_exists ( lua_State * L)
static

Gets a outfit if it exists, nil otherwise.

Does not raise any warnings or errors if fails.

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

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 not found

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

Lua function: get

Definition at line 259 of file nlua_outfit.c.

◆ outfitL_friendlyfire()

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

◆ outfitL_get()

int outfitL_get ( lua_State * L)
static

Gets a outfit.

Will raise an error if fails.

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

◆ outfitL_getAll()

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

◆ outfitL_getShipStat()

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

◆ outfitL_heatFor()

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

◆ outfitL_icon()

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

◆ outfitL_illegality()

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

◆ outfitL_known()

int outfitL_known ( lua_State * L)
static

Gets whether or not the outfit is known to the player, as in they know a spob that sells it or own it.

Definition at line 935 of file nlua_outfit.c.

◆ outfitL_limit()

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

◆ outfitL_mass()

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

◆ outfitL_miss_asteroids()

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

◆ outfitL_miss_ships()

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

◆ outfitL_name()

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

◆ outfitL_nameRaw()

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

◆ outfitL_pointdefense()

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

◆ outfitL_price()

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

◆ outfitL_shortname()

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

◆ outfitL_slot()

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

◆ outfitL_specificStats()

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

◆ outfitL_summary()

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

◆ outfitL_tags()

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 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.

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

Lua function: tags

Definition at line 984 of file nlua_outfit.c.

◆ outfitL_toggleable()

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

◆ outfitL_type()

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

◆ outfitL_typeBroad()

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

◆ outfitL_unique()

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

◆ outfitL_weapStats()

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

Variable Documentation

◆ outfitL_methods

const luaL_Reg outfitL_methods[]
static

Outfit metatable methods.

Definition at line 59 of file nlua_outfit.c.