15#include "nlua_safelanes.h"
19#include "nlua_faction.h"
22#include "nlua_system.h"
71 int faction, standing, onlyknown;
76 if (!lua_isnoneornil(L,1))
80 std = luaL_optstring(L, 2, NULL);
81 if (!lua_isnoneornil(L,3))
85 onlyknown = lua_toboolean(L,4);
89 if ((faction >= 0) && (std != NULL)) {
90 if (strcmp(std,
"friendly")==0)
91 standing |= SAFELANES_FRIENDLY;
92 else if (strcmp(std,
"neutral")==0)
93 standing |= SAFELANES_NEUTRAL;
94 else if (strcmp(std,
"hostile")==0)
95 standing |= SAFELANES_HOSTILE;
96 else if (strcmp(std,
"non-friendly")==0)
97 standing |= SAFELANES_NEUTRAL | SAFELANES_HOSTILE;
98 else if (strcmp(std,
"non-hostile")==0)
99 standing |= SAFELANES_NEUTRAL | SAFELANES_FRIENDLY;
101 return NLUA_ERROR(L,_(
"Unknown standing type '%s'!"), std);
112 for (
int j=0; j<2; j++) {
114 case SAFELANE_LOC_SPOB:
118 case SAFELANE_LOC_DEST_SYS:
123 return NLUA_ERROR( L, _(
"Safe-lane vertex type is invalid.") );
130 for (
int j=0; j<2; j++) {
132 const JumpPoint *jmp;
134 case SAFELANE_LOC_SPOB:
139 return NLUA_ERROR(L, _(
"Spob is invalid"));
143 case SAFELANE_LOC_DEST_SYS:
150 return NLUA_ERROR(L, _(
"Jump is invalid"));
155 return NLUA_ERROR( L, _(
"Safe-lane vertex type is invalid.") );
157 lua_rawseti( L, -2, j+1 );
159 lua_pushstring( L,
"faction" );
162 lua_rawseti( L, -2, i+1 );
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
Header file with generic functions and naev-specifics.
LuaFaction * lua_pushfaction(lua_State *L, LuaFaction faction)
Pushes a faction on the stack.
LuaFaction luaL_validfaction(lua_State *L, int ind)
Gets faction (or faction name) at index, raising an error if type isn't a valid faction.
static int safelanesL_get(lua_State *L)
Lua accessor functions to safe lane information.
static const luaL_Reg safelanesL_methods[]
int nlua_loadSafelanes(nlua_env env)
Loads the safelanes Lua library.
StarSystem * luaL_validsystem(lua_State *L, int ind)
Gets system (or system name) at index raising an error if type doesn't match.
vec2 * lua_pushvector(lua_State *L, vec2 vec)
Pushes a vector on the stack.
SafeLane * safelanes_get(int faction, int standing, const StarSystem *system)
Gets a set of safelanes for a faction and system.
StarSystem * system_getIndex(int id)
Get the system by its index.
JumpPoint * jump_getTarget(const StarSystem *target, const StarSystem *sys)
Less safe version of jump_get that works with pointers.
Spob * spob_getIndex(int ind)
Gets spob by index.
Describes a safe lane, patrolled by a faction, within a system.
SafeLaneLocType point_type[2]
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...