naev 0.12.5
nlua_munition.c File Reference

Handles the Lua munition bindings. More...

#include "nlua_munition.h"
#include "array.h"
#include "nlua.h"
#include "nlua_faction.h"
#include "nlua_outfit.h"
#include "nlua_pilot.h"
#include "nlua_vec2.h"
#include "nluadef.h"
Include dependency graph for nlua_munition.c:

Go to the source code of this file.

Functions

static Weaponmunition_get (LuaMunition *lm)
static int munitionL_eq (lua_State *L)
 Checks to see if munition and p are the same.
static int munitionL_tostring (lua_State *L)
 Gets the munition's current (translated) name or notes it is inexistent.
static int munitionL_exists (lua_State *L)
 Checks to see if a munition still exists.
static int munitionL_clear (lua_State *L)
 Clears all the munitions in the system.
static int munitionL_getAll (lua_State *L)
 Gets all the munitions in the system.
static int munitionL_getInrange (lua_State *L)
 Get munitions in range. Note that this can only get hittable munitions.
static int munitionL_pos (lua_State *L)
 Gets the position of the munition.
static int munitionL_vel (lua_State *L)
 Gets the velocity of the munition.
static int munitionL_faction (lua_State *L)
 Gets the faction of the munition.
static int munitionL_parent (lua_State *L)
 Gets the parent of the munition.
static int munitionL_target (lua_State *L)
 Gets the target of the munition.
static int munitionL_outfit (lua_State *L)
 Gets the outfit corresponding to the munition.
static int munitionL_strength (lua_State *L)
 Gets the strength of a munition.
static int munitionL_strengthSet (lua_State *L)
 Sets the strength of a munition.
int nlua_loadMunition (nlua_env env)
 Loads the munition library.
LuaMunitionlua_tomunition (lua_State *L, int ind)
 Lua bindings to interact with munitions.
LuaMunitionluaL_checkmunition (lua_State *L, int ind)
 Gets munition at index or raises error if there is no munition at index.
WeaponluaL_validmunition (lua_State *L, int ind)
 Makes sure the munition is valid or raises a Lua error.
LuaMunitionlua_pushmunition (lua_State *L, const Weapon *w)
 Pushes a weapon as a munition on the stack.
int lua_ismunition (lua_State *L, int ind)
 Checks to see if ind is a munition.
static int weapon_isHostile (const Weapon *w, const Pilot *p)
 Sees if a weapon is hostile to a pilot or not.

Variables

static const luaL_Reg munitionL_methods []

Detailed Description

Handles the Lua munition bindings.

These bindings control the spobs and systems.

Definition in file nlua_munition.c.

Function Documentation

◆ lua_ismunition()

int lua_ismunition ( lua_State * L,
int ind )

Checks to see if ind is a munition.

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

Definition at line 156 of file nlua_munition.c.

◆ lua_pushmunition()

LuaMunition * lua_pushmunition ( lua_State * L,
const Weapon * w )

Pushes a weapon as a munition on the stack.

Parameters
LLua state to push munition into.
wWeapon to push as munition.
Returns
Newly pushed munition.

Definition at line 139 of file nlua_munition.c.

◆ lua_tomunition()

LuaMunition * lua_tomunition ( lua_State * L,
int ind )

Lua bindings to interact with munitions.

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

Lua module: munition

Gets munition at index.

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

Definition at line 96 of file nlua_munition.c.

◆ luaL_checkmunition()

LuaMunition * luaL_checkmunition ( lua_State * L,
int ind )

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

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

Definition at line 108 of file nlua_munition.c.

◆ luaL_validmunition()

Weapon * luaL_validmunition ( lua_State * L,
int ind )

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

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

Definition at line 123 of file nlua_munition.c.

◆ munition_get()

Weapon * munition_get ( LuaMunition * lm)
static

Definition at line 190 of file nlua_munition.c.

◆ munitionL_clear()

int munitionL_clear ( lua_State * L)
static

Clears all the munitions in the system.

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

Lua function: clear

Definition at line 247 of file nlua_munition.c.

◆ munitionL_eq()

int munitionL_eq ( lua_State * L)
static

Checks to see if munition and p are the same.

Lua usage parameter: if p == p2 then – Munition 'p' and 'p2' match.

Lua function parameter: Munition p Munition to compare. Lua function parameter: Munition comp Munition to compare against. Lua return parameter: boolean true if they are the same.

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

Lua function: __eq

Definition at line 182 of file nlua_munition.c.

◆ munitionL_exists()

int munitionL_exists ( lua_State * L)
static

Checks to see if a munition still exists.

Lua function parameter: Munition m Munition to see if still exists. Lua return parameter: boolean true if the munition still exists.

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

Lua function: exists

Definition at line 235 of file nlua_munition.c.

◆ munitionL_faction()

int munitionL_faction ( lua_State * L)
static

Gets the faction of the munition.

Lua function parameter: Munition m Munition to get property of. Lua return parameter: Faction Faction of the munition.

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

Lua function: faction

Definition at line 386 of file nlua_munition.c.

◆ munitionL_getAll()

int munitionL_getAll ( lua_State * L)
static

Gets all the munitions in the system.

Lua function parameter: boolean onlyhittable Whether or not to only get hittable munitions, or all of them. Lua return parameter: table A table containing all the munitions in the system.

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

Lua function: getAll

Definition at line 262 of file nlua_munition.c.

◆ munitionL_getInrange()

int munitionL_getInrange ( lua_State * L)
static

Get munitions in range. Note that this can only get hittable munitions.

Lua function parameter: Vec2 pos Position from which to get munitions. Lua function parameter: number range Range to get munitions from. Lua function parameter:[opt=nil] Pilot|nil Pilot to check hostility to. Lua return parameter: table A table containing all the munitions found in range.

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

Lua function: getInrange

Definition at line 320 of file nlua_munition.c.

◆ munitionL_outfit()

int munitionL_outfit ( lua_State * L)
static

Gets the outfit corresponding to the munition.

Lua function parameter: Munition m Munition to get corresponding outfit of. Lua return parameter: Outfit The outfit corresponding to the munition.

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

Lua function: outfit

Definition at line 428 of file nlua_munition.c.

◆ munitionL_parent()

int munitionL_parent ( lua_State * L)
static

Gets the parent of the munition.

Lua function parameter: Munition m Munition to get property of. Lua return parameter: Pilot Parent of the munition.

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

Lua function: parent

Definition at line 400 of file nlua_munition.c.

◆ munitionL_pos()

int munitionL_pos ( lua_State * L)
static

Gets the position of the munition.

Lua function parameter: Munition m Munition to get property of. Lua return parameter: Vec2 Position of the munition.

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

Lua function: pos

Definition at line 358 of file nlua_munition.c.

◆ munitionL_strength()

int munitionL_strength ( lua_State * L)
static

Gets the strength of a munition.

Defaults to 1. and only changed when past falloff range or modified by a Lua script.

Lua function parameter: Munition m Munition to get strength of. Lua return parameter: number The corresponding strength value where 1 indicates normal strength.

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

Lua function: strength

See also
strengthSet

Definition at line 447 of file nlua_munition.c.

◆ munitionL_strengthSet()

int munitionL_strengthSet ( lua_State * L)
static

Sets the strength of a munition.

Lua function parameter: Munition m Munition to get strength of. Lua function parameter: number str Strength to set to. A value of 1 indicates normal strength.

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

Lua function: strengthSet

See also
strength

Definition at line 463 of file nlua_munition.c.

◆ munitionL_target()

int munitionL_target ( lua_State * L)
static

Gets the target of the munition.

Lua function parameter: Munition m Munition to get property of. Lua return parameter: Pilot Target of the munition.

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

Lua function: target

Definition at line 414 of file nlua_munition.c.

◆ munitionL_tostring()

int munitionL_tostring ( lua_State * L)
static

Gets the munition's current (translated) name or notes it is inexistent.

Lua usage parameter: tostring(p)

Lua function parameter: Munition p Munition to convert to string. Lua return parameter: string The current name of the munition or "(inexistent munition)" if not existent.

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

Lua function: __tostring

Definition at line 217 of file nlua_munition.c.

◆ munitionL_vel()

int munitionL_vel ( lua_State * L)
static

Gets the velocity of the munition.

Lua function parameter: Munition m Munition to get property of. Lua return parameter: Vec2 Velocity of the munition.

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

Lua function: vel

Definition at line 372 of file nlua_munition.c.

◆ nlua_loadMunition()

int nlua_loadMunition ( nlua_env env)

Loads the munition library.

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

Definition at line 72 of file nlua_munition.c.

◆ weapon_isHostile()

int weapon_isHostile ( const Weapon * w,
const Pilot * p )
static

Sees if a weapon is hostile to a pilot or not.

Parameters
wWeapon to check.
pPilot to see if weapon is hostile to them.

Definition at line 286 of file nlua_munition.c.

Variable Documentation

◆ munitionL_methods

const luaL_Reg munitionL_methods[]
static
Initial value:
= {
{ "__eq", munitionL_eq },
{ "__tostring", munitionL_tostring },
{ "exists", munitionL_exists },
{ "clear", munitionL_clear },
{ "getAll", munitionL_getAll },
{ "getInrange", munitionL_getInrange },
{ "pos", munitionL_pos },
{ "vel", munitionL_vel },
{ "faction", munitionL_faction },
{ "parent", munitionL_parent },
{ "target", munitionL_target },
{ "outfit", munitionL_outfit },
{ "strength", munitionL_strength },
{ "strengthSet", munitionL_strengthSet },
{ 0, 0 },
}
static int munitionL_exists(lua_State *L)
Checks to see if a munition still exists.
static int munitionL_getAll(lua_State *L)
Gets all the munitions in the system.
static int munitionL_pos(lua_State *L)
Gets the position of the munition.
static int munitionL_strengthSet(lua_State *L)
Sets the strength of a munition.
static int munitionL_target(lua_State *L)
Gets the target of the munition.
static int munitionL_getInrange(lua_State *L)
Get munitions in range. Note that this can only get hittable munitions.
static int munitionL_outfit(lua_State *L)
Gets the outfit corresponding to the munition.
static int munitionL_parent(lua_State *L)
Gets the parent of the munition.
static int munitionL_tostring(lua_State *L)
Gets the munition's current (translated) name or notes it is inexistent.
static int munitionL_eq(lua_State *L)
Checks to see if munition and p are the same.
static int munitionL_strength(lua_State *L)
Gets the strength of a munition.
static int munitionL_clear(lua_State *L)
Clears all the munitions in the system.
static int munitionL_faction(lua_State *L)
Gets the faction of the munition.
static int munitionL_vel(lua_State *L)
Gets the velocity of the munition.

Munition metatable methods.

Definition at line 44 of file nlua_munition.c.