naev 0.12.6
nlua_jump.c File Reference

Lua jump module. More...

#include "nlua_jump.h"
#include "land_outfits.h"
#include "map_overlay.h"
#include "nlua_pilot.h"
#include "nlua_system.h"
#include "nlua_vec2.h"
#include "nluadef.h"
Include dependency graph for nlua_jump.c:

Go to the source code of this file.

Functions

static RETURNS_NONNULL JumpPoint * luaL_validjumpSystem (lua_State *L, int ind, int *offset)
 Back-end for luaL_validjump.
static int jumpL_get (lua_State *L)
 Gets a jump.
static int jumpL_eq (lua_State *L)
 You can use the '==' operator within Lua to compare jumps with this.
static int jumpL_tostring (lua_State *L)
 Converts a jump to readable form. Mainly meant to be used for printing.
static int jumpL_reverse (lua_State *L)
 Gets the opposite jump.
static int jumpL_radius (lua_State *L)
 Gets the jump's radius.
static int jumpL_position (lua_State *L)
 Gets the position of the jump in the system.
static int jumpL_angle (lua_State *L)
 Gets the angle of a jump in radians.
static int jumpL_hide (lua_State *L)
 Gets the hide value of a jump in radians.
static int jumpL_hidden (lua_State *L)
 Checks whether a jump is hidden.
static int jumpL_exitonly (lua_State *L)
 Checks whether a jump is exit-only.
static int jumpL_system (lua_State *L)
 Gets the system that a jump point exists in.
static int jumpL_dest (lua_State *L)
 Gets the system that a jump point exits into.
static int jumpL_jumpDist (lua_State *L)
 Gets the distance from the jump point at which the pilot can jump.
static int jumpL_isKnown (lua_State *L)
 Checks to see if a jump is known by the player.
static int jumpL_setKnown (lua_State *L)
 Sets a jump's known state.
int nlua_loadJump (nlua_env env)
 Loads the jump library.
LuaJumplua_tojump (lua_State *L, int ind)
 This module allows you to handle the jumps from Lua.
LuaJumpluaL_checkjump (lua_State *L, int ind)
 Gets jump at index raising an error if isn't a jump.
JumpPoint * luaL_validjump (lua_State *L, int ind)
 Gets a jump directly.
LuaJumplua_pushjump (lua_State *L, LuaJump jump)
 Pushes a jump on the stack.
int lua_isjump (lua_State *L, int ind)
 Checks to see if ind is a jump.

Variables

static const luaL_Reg jump_methods []

Detailed Description

Lua jump module.

Definition in file nlua_jump.c.

Function Documentation

◆ jumpL_angle()

int jumpL_angle ( lua_State * L)
static

Gets the angle of a jump in radians.

Lua usage parameter: v = j:angle() Lua function parameter: Jump j Jump to get the angle of. Lua return parameter: number The angle.

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

Lua function: angle

Definition at line 364 of file nlua_jump.c.

◆ jumpL_dest()

int jumpL_dest ( lua_State * L)
static

Gets the system that a jump point exits into.

Lua usage parameter: v = j:dest() Lua function parameter: Jump j Jump to get the destination of. Lua return parameter: System The jump's destination system.

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

Lua function: dest

Definition at line 425 of file nlua_jump.c.

◆ jumpL_eq()

int jumpL_eq ( lua_State * L)
static

You can use the '==' operator within Lua to compare jumps with this.

Lua usage parameter: if j:__eq( jump.get( "Rhu", "Ruttwi" ) ) then – Do something Lua function parameter: Jump j Jump comparing. Lua function parameter: Jump comp jump to compare against. Lua return parameter: boolean true if both jumps are the same.

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

Lua function: __eq

Definition at line 266 of file nlua_jump.c.

◆ jumpL_exitonly()

int jumpL_exitonly ( lua_State * L)
static

Checks whether a jump is exit-only.

Lua usage parameter: if jump.exitonly("Eneguoz", "Zied") then – The jump point in Eneguoz cannot be entered. Lua function parameter: Jump j Jump to get the exit-only status of. Lua return parameter: boolean Whether the jump is exit-only.

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

Lua function: exitonly

Definition at line 395 of file nlua_jump.c.

◆ jumpL_get()

int jumpL_get ( lua_State * L)
static

Gets a jump.

Possible values of params:

  • string : Gets the jump by system name.
  • system : Gets the jump by system.

Lua usage parameter: j,r = jump.get( "Ogat", "Goddard" ) – Returns the Ogat to Goddard and Goddard to Ogat jumps. Lua function parameter: string|System src See description. Lua function parameter: string|System dest See description. Lua return parameter: Jump Returns the jump. Lua return parameter: Jump Returns the inverse.

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

Lua function: get

Definition at line 233 of file nlua_jump.c.

◆ jumpL_hidden()

int jumpL_hidden ( lua_State * L)
static

Checks whether a jump is hidden.

Lua usage parameter: if not j:hidden() then – Exclude hidden jumps. Lua function parameter: Jump j Jump to get the hidden status of. Lua return parameter: boolean Whether the jump is hidden.

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

Lua function: hidden

Definition at line 379 of file nlua_jump.c.

◆ jumpL_hide()

int jumpL_hide ( lua_State * L)
static

Gets the hide value of a jump in radians.

Lua usage parameter: v = j:hide() Lua function parameter: Jump j Jump to get the hide value of. Lua return parameter: number The hide value.

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

Lua function: hide

Definition at line 349 of file nlua_jump.c.

◆ jumpL_isKnown()

int jumpL_isKnown ( lua_State * L)
static

Checks to see if a jump is known by the player.

Lua usage parameter: b = j:known()

Lua function parameter: Jump j Jump to check if the player knows. Lua return parameter: boolean true if the player knows the jump.

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

Lua function: known

Definition at line 458 of file nlua_jump.c.

◆ jumpL_jumpDist()

int jumpL_jumpDist ( lua_State * L)
static

Gets the distance from the jump point at which the pilot can jump.

Lua usage parameter: d = j:jumpDist( player.pilot() ) Lua function parameter: Jump j Jump to get the jump distance of. Lua function parameter: Pilot p Pilot to get information for. Lua return parameter: number The distance from the jump at which the pilot can jump.

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

Lua function: dest

Definition at line 441 of file nlua_jump.c.

◆ jumpL_position()

int jumpL_position ( lua_State * L)
static

Gets the position of the jump in the system.

Lua usage parameter: v = j:pos() Lua function parameter: Jump j Jump to get the position of. Lua return parameter: Vec2 The position of the jump in the system.

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

Lua function: pos

Definition at line 334 of file nlua_jump.c.

◆ jumpL_radius()

int jumpL_radius ( lua_State * L)
static

Gets the jump's radius.

Lua usage parameter: radius = j:radius() Lua function parameter: Jump j Jump to get the radius of. Lua return parameter: number The jump's radius.

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

Lua function: radius

Definition at line 319 of file nlua_jump.c.

◆ jumpL_reverse()

int jumpL_reverse ( lua_State * L)
static

Gets the opposite jump.

Lua function parameter: Jump j Jump to get the reverse jump of. Lua return parameter: Jump The jump in the opposite direction.

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

Lua function: reverse

Definition at line 301 of file nlua_jump.c.

◆ jumpL_setKnown()

int jumpL_setKnown ( lua_State * L)
static

Sets a jump's known state.

Note that this affects both sides of the jump connection to avoid getting the player locked away.

Lua usage parameter: j:setKnown( false ) – Makes jump unknown. Lua function parameter: Jump j Jump to set known. Lua function parameter:[opt=true] boolean value Whether or not to set as known.

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

Lua function: setKnown

Definition at line 476 of file nlua_jump.c.

◆ jumpL_system()

int jumpL_system ( lua_State * L)
static

Gets the system that a jump point exists in.

Lua usage parameter: s = j:system() Lua function parameter: Jump j Jump to get the system of. Lua return parameter: System The jump's system.

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

Lua function: system

Definition at line 410 of file nlua_jump.c.

◆ jumpL_tostring()

int jumpL_tostring ( lua_State * L)
static

Converts a jump to readable form. Mainly meant to be used for printing.

Lua function parameter: Jump j Jump to print.

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

Lua function: __tostring

Definition at line 282 of file nlua_jump.c.

◆ lua_isjump()

int lua_isjump ( lua_State * L,
int ind )

Checks to see if ind is a jump.

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

Definition at line 202 of file nlua_jump.c.

◆ lua_pushjump()

LuaJump * lua_pushjump ( lua_State * L,
LuaJump jump )

Pushes a jump on the stack.

Parameters
LLua state to push jump into.
jumpJump to push.
Returns
Newly pushed jump.

Definition at line 186 of file nlua_jump.c.

◆ lua_tojump()

LuaJump * lua_tojump ( lua_State * L,
int ind )

This module allows you to handle the jumps from Lua.

Generally you do something like:

j = jump.get("Gamma Polaris", "Apez") -- Get the jump from Gamma Polaris to
Apez if j:known() then -- The jump is known v = j:pos() -- Get the position
-- Do other stuff
end

Lua module: jump

Gets jump at index.

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

Definition at line 95 of file nlua_jump.c.

◆ luaL_checkjump()

LuaJump * luaL_checkjump ( lua_State * L,
int ind )

Gets jump at index raising an error if isn't a jump.

Parameters
LLua state to get jump from.
indIndex to check.
Returns
Jump found at the index in the state.

Definition at line 106 of file nlua_jump.c.

◆ luaL_validjump()

JumpPoint * luaL_validjump ( lua_State * L,
int ind )

Gets a jump directly.

Parameters
LLua state to get jump from.
indIndex to check.
Returns
Jump found at the index in the state.

Definition at line 174 of file nlua_jump.c.

◆ luaL_validjumpSystem()

JumpPoint * luaL_validjumpSystem ( lua_State * L,
int ind,
int * offset )
static

Back-end for luaL_validjump.

Parameters
LLua state to get jump from.
indIndex to check.
[out]offsetHow many Lua arguments were passed.
Returns
Jump found at the index in the state.
See also
luaL_validjump

Definition at line 124 of file nlua_jump.c.

◆ nlua_loadJump()

int nlua_loadJump ( nlua_env env)

Loads the jump library.

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

Definition at line 68 of file nlua_jump.c.

Variable Documentation

◆ jump_methods

const luaL_Reg jump_methods[]
static
Initial value:
= {
{ "get", jumpL_get },
{ "__eq", jumpL_eq },
{ "__tostring", jumpL_tostring },
{ "reverse", jumpL_reverse },
{ "radius", jumpL_radius },
{ "pos", jumpL_position },
{ "angle", jumpL_angle },
{ "hide", jumpL_hide },
{ "hidden", jumpL_hidden },
{ "exitonly", jumpL_exitonly },
{ "system", jumpL_system },
{ "dest", jumpL_dest },
{ "jumpDist", jumpL_jumpDist },
{ "known", jumpL_isKnown },
{ "setKnown", jumpL_setKnown },
{ 0, 0 } }
static int jumpL_hide(lua_State *L)
Gets the hide value of a jump in radians.
Definition nlua_jump.c:349
static int jumpL_reverse(lua_State *L)
Gets the opposite jump.
Definition nlua_jump.c:301
static int jumpL_jumpDist(lua_State *L)
Gets the distance from the jump point at which the pilot can jump.
Definition nlua_jump.c:441
static int jumpL_tostring(lua_State *L)
Converts a jump to readable form. Mainly meant to be used for printing.
Definition nlua_jump.c:282
static int jumpL_exitonly(lua_State *L)
Checks whether a jump is exit-only.
Definition nlua_jump.c:395
static int jumpL_setKnown(lua_State *L)
Sets a jump's known state.
Definition nlua_jump.c:476
static int jumpL_system(lua_State *L)
Gets the system that a jump point exists in.
Definition nlua_jump.c:410
static int jumpL_angle(lua_State *L)
Gets the angle of a jump in radians.
Definition nlua_jump.c:364
static int jumpL_radius(lua_State *L)
Gets the jump's radius.
Definition nlua_jump.c:319
static int jumpL_isKnown(lua_State *L)
Checks to see if a jump is known by the player.
Definition nlua_jump.c:458
static int jumpL_dest(lua_State *L)
Gets the system that a jump point exits into.
Definition nlua_jump.c:425
static int jumpL_eq(lua_State *L)
You can use the '==' operator within Lua to compare jumps with this.
Definition nlua_jump.c:266
static int jumpL_get(lua_State *L)
Gets a jump.
Definition nlua_jump.c:233
static int jumpL_hidden(lua_State *L)
Checks whether a jump is hidden.
Definition nlua_jump.c:379
static int jumpL_position(lua_State *L)
Gets the position of the jump in the system.
Definition nlua_jump.c:334

Jump metatable methods.

Definition at line 44 of file nlua_jump.c.