naev 0.12.5
nlua_pilotoutfit.c File Reference

Handles the Lua pilot outfit (equipped) bindings. More...

#include "nlua_pilotoutfit.h"
#include "array.h"
#include "nlua_asteroid.h"
#include "nlua_munition.h"
#include "nlua_outfit.h"
#include "nlua_pilot.h"
#include "nlua_vec2.h"
#include "nluadef.h"
#include "slots.h"
#include "weapon.h"
Include dependency graph for nlua_pilotoutfit.c:

Go to the source code of this file.

Functions

static int poL_slot (lua_State *L)
 Gets the properties of the outfit slot.
static int poL_outfit (lua_State *L)
 Gets the outfit of the PilotOutfit.
static int poL_state (lua_State *L)
 Sets the state of the PilotOutfit.
static int poL_progress (lua_State *L)
 Sets the state progress of the PilotOutfit.
static int poL_set (lua_State *L)
 Sets a temporary ship stat modifier of the pilot outfit.
static int poL_clear (lua_State *L)
 Clears all the temporary ship stat modifiers of the pilot outfit.
static int poL_munition (lua_State *L)
 Creates a munition.
static int poL_shoot (lua_State *L)
 Shoots at an object.
static int poL_heat (lua_State *L)
 Gets the heat status of the pilot outfit.
static int poL_heatup (lua_State *L)
 Heats up a pilot outfit.
int nlua_loadPilotOutfit (nlua_env env)
 Loads the pilot outfit library.
PilotOutfitSlotlua_topilotoutfit (lua_State *L, int ind)
 Lua bindings to interact with pilot outfits.
PilotOutfitSlotluaL_checkpilotoutfit (lua_State *L, int ind)
 Gets outfit at index or raises error if there is no outfit at index.
PilotOutfitSlotluaL_validpilotoutfit (lua_State *L, int ind)
 Makes sure the outfit is valid or raises a Lua error.
PilotOutfitSlot ** lua_pushpilotoutfit (lua_State *L, PilotOutfitSlot *po)
 Pushes a pilot outfit on the stack.
int lua_ispilotoutfit (lua_State *L, int ind)
 Checks to see if ind is a pilot outfit.
static Target lua_totarget (lua_State *L, int idx)

Variables

int pilotoutfit_modified = 0
static const luaL_Reg poL_methods []

Detailed Description

Handles the Lua pilot outfit (equipped) bindings.

Definition in file nlua_pilotoutfit.c.

Function Documentation

◆ lua_ispilotoutfit()

int lua_ispilotoutfit ( lua_State * L,
int ind )

Checks to see if ind is a pilot outfit.

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

Definition at line 142 of file nlua_pilotoutfit.c.

◆ lua_pushpilotoutfit()

PilotOutfitSlot ** lua_pushpilotoutfit ( lua_State * L,
PilotOutfitSlot * po )

Pushes a pilot outfit on the stack.

Parameters
LLua state to push outfit into.
poPilot outfit to push.
Returns
Newly pushed pilotoutfit.

Definition at line 126 of file nlua_pilotoutfit.c.

◆ lua_topilotoutfit()

PilotOutfitSlot * lua_topilotoutfit ( lua_State * L,
int ind )

Lua bindings to interact with pilot outfits.

Lua module: pilotoutfit

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 78 of file nlua_pilotoutfit.c.

◆ lua_totarget()

Target lua_totarget ( lua_State * L,
int idx )
static

Definition at line 341 of file nlua_pilotoutfit.c.

◆ luaL_checkpilotoutfit()

PilotOutfitSlot * luaL_checkpilotoutfit ( 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 89 of file nlua_pilotoutfit.c.

◆ luaL_validpilotoutfit()

PilotOutfitSlot * luaL_validpilotoutfit ( 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 103 of file nlua_pilotoutfit.c.

◆ nlua_loadPilotOutfit()

int nlua_loadPilotOutfit ( nlua_env env)

Loads the pilot outfit library.

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

Definition at line 60 of file nlua_pilotoutfit.c.

◆ poL_clear()

int poL_clear ( lua_State * L)
static

Clears all the temporary ship stat modifiers of the pilot outfit.

Lua function parameter: PilotOutfit po Pilot outfit to clear temporary modifiers from.

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

Lua function: clear

Definition at line 332 of file nlua_pilotoutfit.c.

◆ poL_heat()

int poL_heat ( lua_State * L)
static

Gets the heat status of the pilot outfit.

Lua function parameter: PilotOutfit po Pilot outfit to get heat of. Lua function parameter: Boolean absolute If true returns the value in kelvin, otherwise it returns how overheated it is with 1. being normal and 0. being overheated. Lua return parameter: Number heat of the pilot outfit in kelvin or closeness to 800 kelvin.

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

Lua function: heat

Definition at line 501 of file nlua_pilotoutfit.c.

◆ poL_heatup()

int poL_heatup ( lua_State * L)
static

Heats up a pilot outfit.

local heat = po:outfit():heatFor( 5 ) -- 5 pulses should heat up fully
...
po:heatup( heat ) -- one pulse

Lua function parameter: PilotOutfit po Pilot outfit to heat up.

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

Lua function: heatup

See also
heatFor

Definition at line 526 of file nlua_pilotoutfit.c.

◆ poL_munition()

int poL_munition ( lua_State * L)
static

Creates a munition.

Lua function parameter: PilotOutfit po Pilot outfit originating the munition. Lua function parameter: Pilot p Pilot generating the munition, used for faction and damaging purposes. Lua function parameter:[opt=po:outfit()] Outfit o Outfit to be used as a reference for the munition. Lua function parameter:[opt=nil] Pilot|Munition|Asteroid|nil t Target pilot to shoot at. Lua function parameter:[opt=p:dir()] number dir Direction the munition should face. Lua function parameter:[opt=p:pos()] Vec2 pos Position to create the munition at. Lua function parameter:[opt=p:vel()] Vec2 vel Initial velocity of the munition. The munition's base velocity gets added to this. Lua function parameter:[opt=false] boolean noaim Whether or not to disable the tracking and aiming framework when shooting. Lua return parameter: Munition The newly created munition.

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

Lua function: munition

Definition at line 385 of file nlua_pilotoutfit.c.

◆ poL_outfit()

int poL_outfit ( lua_State * L)
static

Gets the outfit of the PilotOutfit.

Lua function parameter: PilotOutfit po Pilot outfit to get the outfit of. Lua function parameter: Outfit Outfit corresponding to the Pilot outfit.

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

Lua function: outfit

Definition at line 210 of file nlua_pilotoutfit.c.

◆ poL_progress()

int poL_progress ( lua_State * L)
static

Sets the state progress of the PilotOutfit.

Lua function parameter: PilotOutfit po Pilot outfit to set the state of. Lua function parameter: number progress Progress of the current state with 1 being started and 0 being done.

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

Lua function: progress

Definition at line 292 of file nlua_pilotoutfit.c.

◆ poL_set()

int poL_set ( lua_State * L)
static

Sets a temporary ship stat modifier of the pilot outfit.

Lua function parameter: PilotOutfit po Pilot outfit to set the modifier of. Lua function parameter: string mod Modifier name to set to. Same as in the XML definition. Lua function parameter: number val Value to set the modifier to. In the case of booleans, 0 indicates false, while 1 indicates true.

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

Lua function: set

Definition at line 315 of file nlua_pilotoutfit.c.

◆ poL_shoot()

int poL_shoot ( lua_State * L)
static

Shoots at an object.

Lua function parameter: PilotOutfit po Pilot outfit originating the munition. Lua function parameter: Pilot p Pilot shooting, used for faction and damaging purposes. Lua function parameter:[opt=nil] Pilot|Munition|Asteroid|nil t Target pilot to shoot at. Lua function parameter:[opt=false] boolean stagger Whether or not to stagger similar outfits. Lua return parameter: boolean true if was able to shoot, false otherwise.

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

Lua function: shoot

Definition at line 412 of file nlua_pilotoutfit.c.

◆ poL_slot()

int poL_slot ( lua_State * L)
static

Gets the properties of the outfit slot.

Lua function parameter: PilotOutfit po Pilot outfit to get the outfit of. Lua return parameter: A table with slot properties string "size", string "type", string "property", boolean "required", boolean "exclusive", and boolean "locked". (Strings are English.)

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

Lua function: slot

Definition at line 167 of file nlua_pilotoutfit.c.

◆ poL_state()

int poL_state ( lua_State * L)
static

Sets the state of the PilotOutfit.

Note on setting state("on"): this will bypass and ignore the weapon sets so you can set an outfit on in the update(...) function and it will be set as on until it is toggled off or the state is changed. A single exception is when it is set as "on" during an ontoggle(...) function call that returns true. In that case, it will behave like non-Lua outfits and be turned off whenever it is toggled off again.

Lua function parameter: PilotOutfit po Pilot outfit to set the state of. Lua function parameter: string state State to set the pilot outfit to. Can be either "off", "warmup", "on", or "cooldown".

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

Lua function: state

Definition at line 232 of file nlua_pilotoutfit.c.

Variable Documentation

◆ pilotoutfit_modified

int pilotoutfit_modified = 0

Definition at line 27 of file nlua_pilotoutfit.c.

◆ poL_methods

const luaL_Reg poL_methods[]
static
Initial value:
= {
{ "slot", poL_slot },
{ "outfit", poL_outfit },
{ "state", poL_state },
{ "progress", poL_progress },
{ "set", poL_set },
{ "clear", poL_clear },
{ "munition", poL_munition },
{ "shoot", poL_shoot },
{ "heat", poL_heat },
{ "heatup", poL_heatup },
{ 0, 0 } }
static int poL_progress(lua_State *L)
Sets the state progress of the PilotOutfit.
static int poL_heat(lua_State *L)
Gets the heat status of the pilot outfit.
static int poL_munition(lua_State *L)
Creates a munition.
static int poL_set(lua_State *L)
Sets a temporary ship stat modifier of the pilot outfit.
static int poL_outfit(lua_State *L)
Gets the outfit of the PilotOutfit.
static int poL_heatup(lua_State *L)
Heats up a pilot outfit.
static int poL_shoot(lua_State *L)
Shoots at an object.
static int poL_state(lua_State *L)
Sets the state of the PilotOutfit.
static int poL_clear(lua_State *L)
Clears all the temporary ship stat modifiers of the pilot outfit.
static int poL_slot(lua_State *L)
Gets the properties of the outfit slot.

Pilot outfit metatable methods.

Definition at line 41 of file nlua_pilotoutfit.c.