naev 0.12.5
nlua_system.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
10#include <lauxlib.h>
12
13#include "nlua_system.h"
14
15#include "array.h"
16#include "gatherable.h"
17#include "land_outfits.h"
18#include "map.h"
19#include "map_overlay.h"
20#include "nlua_commodity.h"
21#include "nlua_faction.h"
22#include "nlua_jump.h"
23#include "nlua_spob.h"
24#include "nlua_vec2.h"
25#include "nluadef.h"
26#include "space.h"
27
28/* System metatable methods */
29static int systemL_cur( lua_State *L );
30static int systemL_get( lua_State *L );
31static int systemL_getAll( lua_State *L );
32static int systemL_eq( lua_State *L );
33static int systemL_name( lua_State *L );
34static int systemL_nameRaw( lua_State *L );
35static int systemL_position( lua_State *L );
36static int systemL_faction( lua_State *L );
37static int systemL_background( lua_State *L );
38static int systemL_nebula( lua_State *L );
39static int systemL_interference( lua_State *L );
40static int systemL_jumpdistance( lua_State *L );
41static int systemL_jumpPath( lua_State *L );
42static int systemL_adjacent( lua_State *L );
43static int systemL_jumps( lua_State *L );
44static int systemL_asteroidFields( lua_State *L );
45static int systemL_addGatherable( lua_State *L );
46static int systemL_presences( lua_State *L );
47static int systemL_spobs( lua_State *L );
48static int systemL_presence( lua_State *L );
49static int systemL_radius( lua_State *L );
50static int systemL_isknown( lua_State *L );
51static int systemL_setknown( lua_State *L );
52static int systemL_hidden( lua_State *L );
53static int systemL_setHidden( lua_State *L );
54static int systemL_markerClear( lua_State *L );
55static int systemL_markerAdd( lua_State *L );
56static int systemL_markerRm( lua_State *L );
57static int systemL_reputation( lua_State *L );
58static int systemL_setReputation( lua_State *L );
59static int systemL_tags( lua_State *L );
60
61static const luaL_Reg system_methods[] = {
62 { "cur", systemL_cur },
63 { "get", systemL_get },
64 { "getAll", systemL_getAll },
65 { "__eq", systemL_eq },
66 { "__tostring", systemL_name },
67 { "name", systemL_name },
68 { "nameRaw", systemL_nameRaw },
69 { "pos", systemL_position },
70 { "faction", systemL_faction },
71 { "background", systemL_background },
72 { "nebula", systemL_nebula },
73 { "interference", systemL_interference },
74 { "jumpDist", systemL_jumpdistance },
75 { "jumpPath", systemL_jumpPath },
76 { "adjacentSystems", systemL_adjacent },
77 { "jumps", systemL_jumps },
78 { "asteroidFields", systemL_asteroidFields },
79 { "addGatherable", systemL_addGatherable },
80 { "presences", systemL_presences },
81 { "spobs", systemL_spobs },
82 { "presence", systemL_presence },
83 { "radius", systemL_radius },
84 { "known", systemL_isknown },
85 { "setKnown", systemL_setknown },
86 { "hidden", systemL_hidden },
87 { "setHidden", systemL_setHidden },
88 { "markerClear", systemL_markerClear },
89 { "markerAdd", systemL_markerAdd },
90 { "markerRm", systemL_markerRm },
91 { "reputation", systemL_reputation },
92 { "setReputation", systemL_setReputation },
93 { "tags", systemL_tags },
94 { 0, 0 } };
95
102int nlua_loadSystem( nlua_env env )
103{
104 nlua_register( env, SYSTEM_METATABLE, system_methods, 1 );
105 return 0; /* No error */
106}
107
128LuaSystem lua_tosystem( lua_State *L, int ind )
129{
130 return *( (LuaSystem *)lua_touserdata( L, ind ) );
131}
132
139LuaSystem luaL_checksystem( lua_State *L, int ind )
140{
141 if ( lua_issystem( L, ind ) )
142 return lua_tosystem( L, ind );
143 luaL_typerror( L, ind, SYSTEM_METATABLE );
144 return 0;
145}
146
155StarSystem *luaL_validsystem( lua_State *L, int ind )
156{
157 StarSystem *s;
158
159 if ( lua_issystem( L, ind ) ) {
160 LuaSystem ls = luaL_checksystem( L, ind );
161 s = system_getIndex( ls );
162 } else if ( lua_isstring( L, ind ) )
163 s = system_get( lua_tostring( L, ind ) );
164 else {
165 luaL_typerror( L, ind, SYSTEM_METATABLE );
166 return NULL;
167 }
168
169 if ( s == NULL )
170 NLUA_ERROR( L, _( "System is invalid" ) );
171
172 return s;
173}
174
182LuaSystem *lua_pushsystem( lua_State *L, LuaSystem sys )
183{
184 LuaSystem *s = (LuaSystem *)lua_newuserdata( L, sizeof( LuaSystem ) );
185 *s = sys;
186 luaL_getmetatable( L, SYSTEM_METATABLE );
187 lua_setmetatable( L, -2 );
188 return s;
189}
190
198int lua_issystem( lua_State *L, int ind )
199{
200 int ret;
201
202 if ( lua_getmetatable( L, ind ) == 0 )
203 return 0;
204 lua_getfield( L, LUA_REGISTRYINDEX, SYSTEM_METATABLE );
205
206 ret = 0;
207 if ( lua_rawequal( L, -1, -2 ) ) /* does it have the correct mt? */
208 ret = 1;
209
210 lua_pop( L, 2 ); /* remove both metatables */
211 return ret;
212}
213
222static int systemL_cur( lua_State *L )
223{
225 return 1;
226}
227
242static int systemL_get( lua_State *L )
243{
244 StarSystem *ss;
245 Spob *pnt;
246
247 /* Passing a string (systemname) */
248 if ( lua_isstring( L, 1 ) ) {
249 ss = system_get( lua_tostring( L, 1 ) );
250 }
251 /* Passing a spob */
252 else if ( lua_isspob( L, 1 ) ) {
253 pnt = luaL_validspob( L, 1 );
254 ss = system_get( spob_getSystemName( pnt->name ) );
255 } else if ( lua_issystem( L, 1 ) ) {
256 lua_pushvalue( L, 1 );
257 return 1;
258 } else
259 NLUA_INVALID_PARAMETER( L, 1 );
260
261 /* Error checking. */
262 if ( ss == NULL )
263 return NLUA_ERROR( L, _( "No matching systems found." ) );
264
265 /* return the system */
266 lua_pushsystem( L, system_index( ss ) );
267 return 1;
268}
269
275static int systemL_getAll( lua_State *L )
276{
277 StarSystem *sys = system_getAll();
278 lua_newtable( L );
279 for ( int i = 0; i < array_size( sys ); i++ ) {
280 lua_pushsystem( L, system_index( &sys[i] ) );
281 lua_rawseti( L, -2, i + 1 );
282 }
283 return 1;
284}
285
298static int systemL_eq( lua_State *L )
299{
300 LuaSystem a, b;
301 a = luaL_checksystem( L, 1 );
302 b = luaL_checksystem( L, 2 );
303 if ( a == b )
304 lua_pushboolean( L, 1 );
305 else
306 lua_pushboolean( L, 0 );
307 return 1;
308}
309
323static int systemL_name( lua_State *L )
324{
325 const StarSystem *sys = luaL_validsystem( L, 1 );
326 lua_pushstring( L, system_name( sys ) );
327 return 1;
328}
329
337static int systemL_position( lua_State *L )
338{
339 const StarSystem *sys = luaL_validsystem( L, 1 );
340 lua_pushvector( L, sys->pos );
341 return 1;
342}
343
357static int systemL_nameRaw( lua_State *L )
358{
359 StarSystem *sys = luaL_validsystem( L, 1 );
360 lua_pushstring( L, sys->name );
361 return 1;
362}
363
371static int systemL_faction( lua_State *L )
372{
373 const StarSystem *s = luaL_validsystem( L, 1 );
374 if ( s->faction == -1 )
375 return 0;
376 lua_pushfaction( L, s->faction );
377 return 1;
378}
379
387static int systemL_background( lua_State *L )
388{
389 StarSystem *s = luaL_validsystem( L, 1 );
390 if ( s->background == NULL )
391 return 0;
392 lua_pushstring( L, s->background );
393 return 1;
394}
395
406static int systemL_nebula( lua_State *L )
407{
408 StarSystem *s = luaL_validsystem( L, 1 );
409 /* Push the density and volatility. */
410 lua_pushnumber( L, s->nebu_density );
411 lua_pushnumber( L, s->nebu_volatility );
412 return 2;
413}
414
422static int systemL_interference( lua_State *L )
423{
424 StarSystem *s = luaL_validsystem( L, 1 );
425 lua_pushnumber( L, s->interference );
426 return 1;
427}
428
451static int systemL_jumpdistance( lua_State *L )
452{
453 StarSystem *sys;
454 StarSystem **s;
455 StarSystem *start, *goal;
456 int h, k;
457
458 sys = luaL_validsystem( L, 1 );
459 h = lua_toboolean( L, 3 );
460 k = !lua_toboolean( L, 4 );
461
462 if ( !lua_isnoneornil( L, 2 ) ) {
463 goal = luaL_validsystem( L, 2 );
464 start = sys;
465 } else {
466 goal = sys;
467 start = cur_system;
468 }
469
470 /* Trivial case same system. */
471 if ( start->id == goal->id ) {
472 lua_pushnumber( L, 0. );
473 return 1;
474 }
475
476 s = map_getJumpPath( start, NULL, goal, k, h, NULL, NULL );
477 if ( s == NULL ) {
478 lua_pushnumber( L, HUGE_VAL );
479 return 1;
480 }
481
482 lua_pushnumber( L, array_size( s ) );
483 array_free( s );
484 return 1;
485}
486
510static int systemL_jumpPath( lua_State *L )
511{
512 LuaJump lj;
513 StarSystem *sys, *sysp;
514 StarSystem **s;
515 int sid, pushed, h;
516
517 h = lua_toboolean( L, 3 );
518
519 /* Foo to Bar */
520 sys = luaL_validsystem( L, 1 );
521 sid = sys->id;
522 sysp = luaL_validsystem( L, 2 );
523
524 s = map_getJumpPath( sys, NULL, sysp, 1, h, NULL, NULL );
525 if ( s == NULL )
526 return 0;
527
528 /* Create the jump table. */
529 lua_newtable( L );
530 pushed = 0;
531
532 /* Map path doesn't contain the start system, push it manually. */
533 lj.srcid = sid;
534 lj.destid = s[0]->id;
535
536 lua_pushjump( L, lj ); /* value. */
537 lua_rawseti( L, -2, ++pushed );
538
539 for ( int i = 0; i < array_size( s ) - 1; i++ ) {
540 lj.srcid = s[i]->id;
541 lj.destid = s[i + 1]->id;
542
543 lua_pushjump( L, lj ); /* value. */
544 lua_rawseti( L, -2, ++pushed );
545 }
546 array_free( s );
547
548 return 1;
549}
550
563static int systemL_adjacent( lua_State *L )
564{
565 int id, h;
566 StarSystem *s;
567
568 id = 1;
569 s = luaL_validsystem( L, 1 );
570 h = lua_toboolean( L, 2 );
571
572 /* Push all adjacent systems. */
573 lua_newtable( L );
574 for ( int i = 0; i < array_size( s->jumps ); i++ ) {
575 LuaSystem sysp;
576 if ( jp_isFlag( &s->jumps[i], JP_EXITONLY ) )
577 continue;
578 if ( !h && jp_isFlag( &s->jumps[i], JP_HIDDEN ) )
579 continue;
580 sysp = system_index( s->jumps[i].target );
581 lua_pushsystem( L, sysp ); /* value. */
582 lua_rawseti( L, -2, id++ );
583 }
584
585 return 1;
586}
587
598static int systemL_jumps( lua_State *L )
599{
600 StarSystem *s = luaL_validsystem( L, 1 );
601 int exitonly = lua_toboolean( L, 2 );
602 int pushed = 0;
603
604 /* Push all jumps. */
605 lua_newtable( L );
606 for ( int i = 0; i < array_size( s->jumps ); i++ ) {
607 LuaJump lj;
608 /* Skip exit-only jumps if requested. */
609 if ( ( exitonly ) && ( jp_isFlag( &s->jumps[i], JP_EXITONLY ) ) )
610 continue;
611
612 lj.srcid = s->id;
613 lj.destid = s->jumps[i].targetid;
614 lua_pushjump( L, lj ); /* value. */
615 lua_rawseti( L, -2, ++pushed );
616 }
617
618 return 1;
619}
620
631static int systemL_asteroidFields( lua_State *L )
632{
633 StarSystem *s = luaL_validsystem( L, 1 );
634 /* Push all jumps. */
635 lua_newtable( L );
636 for ( int i = 0; i < array_size( s->asteroids ); i++ ) {
637 lua_newtable( L );
638
639 lua_pushinteger( L, i + 1 );
640 lua_setfield( L, -2, "id" );
641
642 lua_pushvector( L, s->asteroids[i].pos );
643 lua_setfield( L, -2, "pos" );
644
645 lua_pushnumber( L, s->asteroids[i].density );
646 lua_setfield( L, -2, "density" );
647
648 lua_pushnumber( L, s->asteroids[i].radius );
649 lua_setfield( L, -2, "radius" );
650
651 lua_rawseti( L, -2, i + 1 );
652 }
653 return 1;
654}
655
672static int systemL_addGatherable( lua_State *L )
673{
674 int nb;
675 unsigned int player_only;
676 Commodity *commodity;
677 vec2 *pos, *vel;
678 vec2 zero = { .x = 0., .y = 0., .mod = 0., .angle = 0. };
679 double lifelength;
680
681 /* Handle parameters. */
682 commodity = luaL_validcommodity( L, 1 );
683 nb = luaL_checkint( L, 2 );
684 pos = luaL_optvector( L, 3, &zero );
685 vel = luaL_optvector( L, 4, &zero );
686 lifelength = luaL_optnumber( L, 5, -1. ); /* -1. means random life length. */
687 player_only = lua_toboolean( L, 6 );
688
689 lua_pushnumber(
690 L, gatherable_init( commodity, pos, vel, lifelength, nb, player_only ) );
691 return 1;
692}
693
710static int systemL_presences( lua_State *L )
711{
712 StarSystem *s = luaL_validsystem( L, 1 );
713 /* Return result in table */
714 lua_newtable( L );
715 for ( int i = 0; i < array_size( s->presence ); i++ ) {
716 /* Only return positive presences. */
717 if ( s->presence[i].value <= 0 )
718 continue;
719
720 lua_pushstring( L, faction_name( s->presence[i].faction ) ); /* t, k */
721 lua_pushnumber( L, s->presence[i].value ); /* t, k, v */
722 lua_settable( L, -3 ); /* t */
723 /* allows syntax foo = system.presences(); if foo["bar"] then ... end */
724 }
725 return 1;
726}
727
739static int systemL_spobs( lua_State *L )
740{
741 const StarSystem *s = luaL_validsystem( L, 1 );
742 /* Push all spobs. */
743 lua_newtable( L );
744 for ( int i = 0; i < array_size( s->spobs ); i++ ) {
745 lua_pushspob( L, spob_index( s->spobs[i] ) ); /* value */
746 lua_rawseti( L, -2, i + 1 );
747 }
748 return 1;
749}
750
769static int systemL_presence( lua_State *L )
770{
771 StarSystem *sys;
772 int *fct;
773 double presence;
774 int used;
775
776 /* Get parameters. */
777 sys = luaL_validsystem( L, 1 );
778
779 /* Allow fall-through. */
780 used = 0;
781 fct = NULL;
782
783 /* Get the second parameter. */
784 if ( lua_isstring( L, 2 ) ) {
785 /* A string command has been given. */
786 const char *cmd = lua_tostring( L, 2 );
787 used = 1;
788
789 /* Check the command string and get the appropriate faction group.*/
790 if ( strcmp( cmd, "all" ) == 0 )
791 fct = faction_getGroup( 0 );
792 else if ( strcmp( cmd, "friendly" ) == 0 )
793 fct = faction_getGroup( 1 );
794 else if ( strcmp( cmd, "hostile" ) == 0 )
795 fct = faction_getGroup( 3 );
796 else if ( strcmp( cmd, "neutral" ) == 0 )
797 fct = faction_getGroup( 2 );
798 else /* Invalid command string. */
799 used = 0;
800 }
801
802 if ( !used ) {
803 /* A faction id was given. */
804 int f = luaL_validfaction( L, 2 );
805 fct = array_create( int );
806 array_push_back( &fct, f );
807 }
808
809 /* Add up the presence values. */
810 presence = 0;
811 for ( int i = 0; i < array_size( fct ); i++ ) {
812 /* Only count positive presences. */
813 double v = system_getPresence( sys, fct[i] );
814 if ( v > 0 )
815 presence += v;
816 }
817
818 /* Clean up after ourselves. */
819 array_free( fct );
820
821 /* Push it back to Lua. */
822 lua_pushnumber( L, presence );
823 return 1;
824}
825
837static int systemL_radius( lua_State *L )
838{
839 StarSystem *sys = luaL_validsystem( L, 1 );
840 lua_pushnumber( L, sys->radius );
841 return 1;
842}
843
853static int systemL_isknown( lua_State *L )
854{
855 const StarSystem *sys = luaL_validsystem( L, 1 );
856 lua_pushboolean( L, sys_isKnown( sys ) );
857 return 1;
858}
859
870static int systemL_setknown( lua_State *L )
871{
872 int b, r;
873 StarSystem *sys;
874
875 r = 0;
876 sys = luaL_validsystem( L, 1 );
877 b = lua_toboolean( L, 2 );
878 if ( lua_gettop( L ) > 2 )
879 r = lua_toboolean( L, 3 );
880
881 if ( b )
882 sys_setFlag( sys, SYSTEM_KNOWN );
883 else
884 sys_rmFlag( sys, SYSTEM_KNOWN );
885
886 if ( r ) {
887 if ( b ) {
888 for ( int i = 0; i < array_size( sys->spobs ); i++ )
889 spob_setKnown( sys->spobs[i] );
890 for ( int i = 0; i < array_size( sys->jumps ); i++ )
891 jp_setFlag( &sys->jumps[i], JP_KNOWN );
892 } else {
893 for ( int i = 0; i < array_size( sys->spobs ); i++ )
894 spob_rmFlag( sys->spobs[i], SPOB_KNOWN );
895 for ( int i = 0; i < array_size( sys->jumps ); i++ )
896 jp_rmFlag( &sys->jumps[i], JP_KNOWN );
897 }
898 }
899
900 /* Update outfits image array. */
902 ovr_refresh(); /* Update overlay as necessary. */
903
904 return 0;
905}
906
916static int systemL_hidden( lua_State *L )
917{
918 const StarSystem *sys = luaL_validsystem( L, 1 );
919 lua_pushboolean( L, sys_isFlag( sys, SYSTEM_HIDDEN ) );
920 return 1;
921}
922
932static int systemL_setHidden( lua_State *L )
933{
934 StarSystem *sys = luaL_validsystem( L, 1 );
935 int b = lua_toboolean( L, 2 );
936 if ( b )
937 sys_setFlag( sys, SYSTEM_HIDDEN );
938 else
939 sys_rmFlag( sys, SYSTEM_HIDDEN );
940 return 0;
941}
942
953static int systemL_markerClear( lua_State *L )
954{
955 (void)L;
956 ovr_mrkClear();
957 return 0;
958}
959
973static int systemL_markerAdd( lua_State *L )
974{
975 const char *str;
976 vec2 *vec;
977 unsigned int id;
978 double r;
979
980 /* Handle parameters. */
981 vec = luaL_checkvector( L, 1 );
982 str = luaL_optstring( L, 2, NULL );
983 r = luaL_optnumber( L, 3, -1. );
984
985 /* Create marker. */
986 if ( r < 0. )
987 id = ovr_mrkAddPoint( str, vec->x, vec->y );
988 else
989 id = ovr_mrkAddCircle( str, vec->x, vec->y, r );
990 lua_pushnumber( L, id );
991 return 1;
992}
993
1002static int systemL_markerRm( lua_State *L )
1003{
1004 unsigned int id = luaL_checklong( L, 1 );
1005 ovr_mrkRm( id );
1006 return 0;
1007}
1008
1020static int systemL_reputation( lua_State *L )
1021{
1022 const StarSystem *sys = luaL_validsystem( L, 1 );
1023 if ( lua_isnoneornil( L, 2 ) ) {
1024 lua_newtable( L );
1025 for ( int i = 0; i < array_size( sys->presence ); i++ ) {
1026 const char *name = faction_name( sys->presence[i].faction );
1027 lua_pushnumber( L, sys->presence[i].local );
1028 lua_setfield( L, -2, name );
1029 }
1030 return 1;
1031 }
1032
1033 int f = luaL_validfaction( L, 2 );
1034 for ( int i = 0; i < array_size( sys->presence ); i++ ) {
1035 if ( sys->presence[i].faction == f ) {
1036 lua_pushnumber( L, sys->presence[i].local );
1037 return 1;
1038 }
1039 }
1040 lua_pushnumber( L, faction_reputation( f ) );
1041 return 1;
1042}
1043
1052static int systemL_setReputation( lua_State *L )
1053{
1054 StarSystem *sys = luaL_validsystem( L, 1 );
1055 int f = luaL_validfaction( L, 2 );
1056 double m = luaL_checknumber( L, 3 );
1057 SystemPresence *sp = system_getFactionPresence( sys, f );
1058 if ( sp != NULL )
1059 sp->local = m;
1060 faction_updateSingle( f ); /* Brute-force propagate to global. */
1061 return 0;
1062}
1063
1076static int systemL_tags( lua_State *L )
1077{
1078 const StarSystem *s = luaL_validsystem( L, 1 );
1079 return nlua_helperTags( L, 2, s->tags );
1080}
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
Definition array.h:170
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
Definition array.h:179
#define array_push_back(ptr_array, element)
Adds a new element at the end of the array.
Definition array.h:134
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
Definition array.h:93
int * faction_getGroup(int which)
Returns an array of faction ids.
Definition faction.c:2294
const char * faction_name(int f)
Gets a factions "real" (internal) name.
Definition faction.c:331
double faction_reputation(int f)
Gets the player's standing with a faction.
Definition faction.c:1129
int gatherable_init(const Commodity *com, const vec2 *pos, const vec2 *vel, double lifeleng, int qtt, unsigned int player_only)
Initializes a gatherable object.
Definition gatherable.c:68
void outfits_updateEquipmentOutfits(void)
Updates the outfitter and equipment outfit image arrays.
int nlua_helperTags(lua_State *L, int idx, char *const *tags)
Helper function to deal with tags.
Definition nlua.c:1118
Commodity * luaL_validcommodity(lua_State *L, int ind)
Makes sure the commodity is valid or raises a Lua error.
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.
LuaJump * lua_pushjump(lua_State *L, LuaJump jump)
Pushes a jump on the stack.
Definition nlua_jump.c:186
LuaSpob * lua_pushspob(lua_State *L, LuaSpob spob)
Pushes a spob on the stack.
Definition nlua_spob.c:203
Spob * luaL_validspob(lua_State *L, int ind)
Gets a spob directly.
Definition nlua_spob.c:177
int lua_isspob(lua_State *L, int ind)
Checks to see if ind is a spob.
Definition nlua_spob.c:218
static int systemL_name(lua_State *L)
Returns the system's translated name.
static int systemL_adjacent(lua_State *L)
Gets all the adjacent systems to a system.
static int systemL_position(lua_State *L)
Returns the position of the system.
static int systemL_eq(lua_State *L)
Check systems for equality.
LuaSystem luaL_checksystem(lua_State *L, int ind)
Gets system at index raising an error if type doesn't match.
static int systemL_faction(lua_State *L)
Gets system faction.
static int systemL_markerClear(lua_State *L)
Clears the system markers.
static int systemL_setReputation(lua_State *L)
Sets the stored local reputation of a system.
static int systemL_markerAdd(lua_State *L)
Adds a system marker.
int nlua_loadSystem(nlua_env env)
Loads the system library.
LuaSystem * lua_pushsystem(lua_State *L, LuaSystem sys)
Pushes a system on the stack.
static int systemL_presence(lua_State *L)
Gets the presence in the system.
static int systemL_jumpPath(lua_State *L)
Gets jump path from current system, or to another.
static int systemL_interference(lua_State *L)
Gets the system's interference level.
static int systemL_addGatherable(lua_State *L)
Adds a gatherable object.
static int systemL_setHidden(lua_State *L)
Sets a system to be hidden to the player.
static int systemL_markerRm(lua_State *L)
Removes a system marker.
static int systemL_reputation(lua_State *L)
Gets the stored local reputation of a system.
static const luaL_Reg system_methods[]
Definition nlua_system.c:61
static int systemL_asteroidFields(lua_State *L)
Gets all the asteroid fields in a system.
static int systemL_hidden(lua_State *L)
Checks to see if a system is hidden by the player.
static int systemL_background(lua_State *L)
Gets system background.
static int systemL_nebula(lua_State *L)
Gets the system's nebula parameters.
static int systemL_tags(lua_State *L)
Gets the system tags.
StarSystem * luaL_validsystem(lua_State *L, int ind)
Gets system (or system name) at index raising an error if type doesn't match.
static int systemL_jumps(lua_State *L)
Gets all the jumps in a system.
static int systemL_presences(lua_State *L)
Returns the factions that have presence in a system and their respective presence values....
static int systemL_isknown(lua_State *L)
Checks to see if a system is known by the player.
static int systemL_spobs(lua_State *L)
Gets the spobs in a system.
static int systemL_jumpdistance(lua_State *L)
Gets jump distance from current system, or to another.
LuaSystem lua_tosystem(lua_State *L, int ind)
Lua system module.
static int systemL_cur(lua_State *L)
Gets the current system.
static int systemL_setknown(lua_State *L)
Sets a system's known state.
static int systemL_get(lua_State *L)
Gets a system.
static int systemL_getAll(lua_State *L)
Gets all the systems. Lua return parameter: {System,...} A list of all the systems.
static int systemL_radius(lua_State *L)
Gets the radius of the system.
static int systemL_nameRaw(lua_State *L)
Returns the system's raw (untranslated) name.
int lua_issystem(lua_State *L, int ind)
Checks to see if ind is a system.
vec2 * luaL_checkvector(lua_State *L, int ind)
Gets vector at index making sure type is valid.
Definition nlua_vec2.c:130
vec2 * lua_pushvector(lua_State *L, vec2 vec)
Pushes a vector on the stack.
Definition nlua_vec2.c:145
StarSystem * system_getIndex(int id)
Get the system by its index.
Definition space.c:1038
int spob_index(const Spob *p)
Gets the ID of a spob.
Definition space.c:1158
StarSystem * system_getAll(void)
Gets an array (array.h) of all star systems.
Definition space.c:925
StarSystem * system_get(const char *sysname)
Get the system from its name.
Definition space.c:1007
void spob_setKnown(Spob *p)
Sets a spob's known status, if it's real.
Definition space.c:1174
StarSystem * cur_system
Definition space.c:110
double system_getPresence(const StarSystem *sys, int faction)
Get the presence of a faction in a system.
Definition space.c:4537
const char * spob_getSystemName(const char *spobname)
Get the name of a system from a spobname.
Definition space.c:1082
int system_index(const StarSystem *sys)
Gets the index of a star system.
Definition space.c:1049
Represents a commodity.
Definition commodity.h:57
Lua jump Wrapper.
Definition nlua_jump.h:14
int destid
Definition nlua_jump.h:16
int srcid
Definition nlua_jump.h:15
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
Definition space.h:102
char * name
Definition space.h:105
Represents presence in a system.
Definition space.h:228
double local
Definition space.h:236
Represents a 2d vector.
Definition vec2.h:45
double y
Definition vec2.h:47
double x
Definition vec2.h:46