naev 0.10.4
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>
11
12#include "naev.h"
15#include "nlua_system.h"
16
17#include "array.h"
18#include "land.h"
19#include "land_outfits.h"
20#include "log.h"
21#include "gatherable.h"
22#include "map.h"
23#include "map_overlay.h"
24#include "nebula.h"
25#include "nlua_commodity.h"
26#include "nlua_faction.h"
27#include "nlua_jump.h"
28#include "nlua_spob.h"
29#include "nlua_vec2.h"
30#include "nluadef.h"
31#include "rng.h"
32#include "space.h"
33
34/* System metatable methods */
35static int systemL_cur( lua_State *L );
36static int systemL_get( lua_State *L );
37static int systemL_getAll( lua_State *L );
38static int systemL_eq( lua_State *L );
39static int systemL_name( lua_State *L );
40static int systemL_nameRaw( lua_State *L );
41static int systemL_position( lua_State *L );
42static int systemL_faction( lua_State *L );
43static int systemL_background( lua_State *L );
44static int systemL_nebula( lua_State *L );
45static int systemL_interference( lua_State *L );
46static int systemL_jumpdistance( lua_State *L );
47static int systemL_jumpPath( lua_State *L );
48static int systemL_adjacent( lua_State *L );
49static int systemL_jumps( lua_State *L );
50static int systemL_asteroidFields( lua_State *L );
51static int systemL_addGatherable( lua_State *L );
52static int systemL_presences( lua_State *L );
53static int systemL_spobs( lua_State *L );
54static int systemL_presence( lua_State *L );
55static int systemL_radius( lua_State *L );
56static int systemL_isknown( lua_State *L );
57static int systemL_setknown( lua_State *L );
58static int systemL_hidden( lua_State *L );
59static int systemL_setHidden( lua_State *L );
60static int systemL_markerClear( lua_State *L );
61static int systemL_markerAdd( lua_State *L );
62static int systemL_markerRm( lua_State *L );
63static int systemL_tags( lua_State *L );
64static const luaL_Reg system_methods[] = {
65 { "cur", systemL_cur },
66 { "get", systemL_get },
67 { "getAll", systemL_getAll },
68 { "__eq", systemL_eq },
69 { "__tostring", systemL_name },
70 { "name", systemL_name },
71 { "nameRaw", systemL_nameRaw },
72 { "pos", systemL_position },
73 { "faction", systemL_faction },
74 { "background", systemL_background },
75 { "nebula", systemL_nebula },
76 { "interference", systemL_interference },
77 { "jumpDist", systemL_jumpdistance },
78 { "jumpPath", systemL_jumpPath },
79 { "adjacentSystems", systemL_adjacent },
80 { "jumps", systemL_jumps },
81 { "asteroidFields", systemL_asteroidFields },
82 { "addGatherable", systemL_addGatherable },
83 { "presences", systemL_presences },
84 { "spobs", systemL_spobs },
85 { "presence", systemL_presence },
86 { "radius", systemL_radius },
87 { "known", systemL_isknown },
88 { "setKnown", systemL_setknown },
89 { "hidden", systemL_hidden },
90 { "setHidden", systemL_setHidden },
91 { "markerClear", systemL_markerClear },
92 { "markerAdd", systemL_markerAdd },
93 { "markerRm", systemL_markerRm },
94 { "tags", systemL_tags },
95 {0,0}
96};
104int nlua_loadSystem( nlua_env env )
105{
106 nlua_register(env, SYSTEM_METATABLE, system_methods, 1);
107 return 0; /* No error */
108}
109
130LuaSystem lua_tosystem( lua_State *L, int ind )
131{
132 return *((LuaSystem*) lua_touserdata(L,ind));
133}
141LuaSystem luaL_checksystem( lua_State *L, int ind )
142{
143 if (lua_issystem(L,ind))
144 return lua_tosystem(L,ind);
145 luaL_typerror(L, ind, SYSTEM_METATABLE);
146 return 0;
147}
148
156StarSystem* luaL_validsystem( lua_State *L, int ind )
157{
158 LuaSystem ls;
159 StarSystem *s;
160
161 if (lua_issystem(L, ind)) {
162 ls = luaL_checksystem(L, ind);
163 s = system_getIndex( ls );
164 }
165 else if (lua_isstring(L, ind))
166 s = system_get( lua_tostring(L, ind) );
167 else {
168 luaL_typerror(L, ind, SYSTEM_METATABLE);
169 return NULL;
170 }
171
172 if (s == NULL)
173 NLUA_ERROR(L, _("System is invalid"));
174
175 return s;
176}
177
185LuaSystem* lua_pushsystem( lua_State *L, LuaSystem sys )
186{
187 LuaSystem *s = (LuaSystem*) lua_newuserdata(L, sizeof(LuaSystem));
188 *s = sys;
189 luaL_getmetatable(L, SYSTEM_METATABLE);
190 lua_setmetatable(L, -2);
191 return s;
192}
193
201int lua_issystem( lua_State *L, int ind )
202{
203 int ret;
204
205 if (lua_getmetatable(L,ind)==0)
206 return 0;
207 lua_getfield(L, LUA_REGISTRYINDEX, SYSTEM_METATABLE);
208
209 ret = 0;
210 if (lua_rawequal(L, -1, -2)) /* does it have the correct mt? */
211 ret = 1;
212
213 lua_pop(L, 2); /* remove both metatables */
214 return ret;
215}
216
225static int systemL_cur( lua_State *L )
226{
228 return 1;
229}
230
245static int systemL_get( lua_State *L )
246{
247 StarSystem *ss;
248 Spob *pnt;
249
250 /* Passing a string (systemname) */
251 if (lua_isstring(L,1)) {
252 ss = system_get( lua_tostring(L,1) );
253 }
254 /* Passing a spob */
255 else if (lua_isspob(L,1)) {
256 pnt = luaL_validspob(L,1);
257 ss = system_get( spob_getSystem( pnt->name ) );
258 }
259 else if (lua_issystem(L,1)) {
260 lua_pushvalue(L,1);
261 return 1;
262 }
263 else
264 NLUA_INVALID_PARAMETER(L);
265
266 /* Error checking. */
267 if (ss == NULL) {
268 NLUA_ERROR(L, _("No matching systems found."));
269 return 0;
270 }
271
272 /* return the system */
274 return 1;
275}
276
282static int systemL_getAll( lua_State *L )
283{
284 StarSystem *sys = system_getAll();
285 lua_newtable(L);
286 for (int i=0; i<array_size(sys); i++) {
287 lua_pushsystem( L, system_index( &sys[i] ) );
288 lua_rawseti( L, -2, i+1 );
289 }
290 return 1;
291}
292
305static int systemL_eq( lua_State *L )
306{
307 LuaSystem a, b;
308 a = luaL_checksystem(L,1);
309 b = luaL_checksystem(L,2);
310 if (a == b)
311 lua_pushboolean(L,1);
312 else
313 lua_pushboolean(L,0);
314 return 1;
315}
316
330static int systemL_name( lua_State *L )
331{
332 StarSystem *sys = luaL_validsystem(L,1);
333 lua_pushstring(L, _(sys->name));
334 return 1;
335}
336
344static int systemL_position( lua_State *L )
345{
346 StarSystem *sys = luaL_validsystem(L,1);
347 lua_pushvector(L, sys->pos);
348 return 1;
349}
350
364static int systemL_nameRaw( lua_State *L )
365{
366 StarSystem *sys = luaL_validsystem(L,1);
367 lua_pushstring(L, sys->name);
368 return 1;
369}
370
378static int systemL_faction( lua_State *L )
379{
380 StarSystem *s = luaL_validsystem(L,1);
381 if (s->faction == -1)
382 return 0;
383 lua_pushfaction(L,s->faction);
384 return 1;
385
386}
387
395static int systemL_background( lua_State *L )
396{
397 StarSystem *s = luaL_validsystem(L,1);
398 if (s->background==NULL)
399 return 0;
400 lua_pushstring(L,s->background);
401 return 1;
402
403}
404
416static int systemL_nebula( lua_State *L )
417{
418 StarSystem *s = luaL_validsystem(L,1);
419 /* Push the density and volatility. */
420 lua_pushnumber(L, s->nebu_density);
421 lua_pushnumber(L, s->nebu_volatility);
422 return 2;
423}
424
432static int systemL_interference( lua_State *L )
433{
434 StarSystem *s = luaL_validsystem(L,1);
435 lua_pushnumber( L, s->interference );
436 return 1;
437}
438
458static int systemL_jumpdistance( lua_State *L )
459{
460 StarSystem *sys;
461 StarSystem **s;
462 const char *start, *goal;
463 int h, k;
464
465 sys = luaL_validsystem(L,1);
466 start = sys->name;
467 h = lua_toboolean(L,3);
468 k = !lua_toboolean(L,4);
469
470 if (lua_gettop(L) > 1) {
471 if (lua_isstring(L,2))
472 goal = lua_tostring(L,2);
473 else if (lua_issystem(L,2)) {
474 StarSystem *sysp = luaL_validsystem(L,2);
475 goal = sysp->name;
476 }
477 else
478 NLUA_INVALID_PARAMETER(L);
479 }
480 else {
481 goal = sys->name;
482 start = cur_system->name;
483 }
484
485 /* Trivial case same system. */
486 if (strcmp(start,goal)==0) {
487 lua_pushnumber(L, 0.);
488 return 1;
489 }
490
491 s = map_getJumpPath( start, goal, k, h, NULL );
492 if (s==NULL) {
493 lua_pushnumber(L, HUGE_VAL);
494 return 1;
495 }
496
497 lua_pushnumber(L,array_size(s));
498 array_free(s);
499 return 1;
500}
501
522static int systemL_jumpPath( lua_State *L )
523{
524 LuaJump lj;
525 StarSystem *sys, *sysp;
526 StarSystem **s;
527 int sid, pushed, h;
528 const char *start, *goal;
529
530 h = lua_toboolean(L,3);
531
532 /* Foo to Bar */
533 sys = luaL_validsystem(L,1);
534 start = sys->name;
535 sid = sys->id;
536 sysp = luaL_validsystem(L,2);
537 goal = sysp->name;
538
539 s = map_getJumpPath( start, goal, 1, h, NULL );
540 if (s == NULL)
541 return 0;
542
543 /* Create the jump table. */
544 lua_newtable(L);
545 pushed = 0;
546
547 /* Map path doesn't contain the start system, push it manually. */
548 lj.srcid = sid;
549 lj.destid = s[0]->id;
550
551 lua_pushjump(L, lj); /* value. */
552 lua_rawseti(L, -2, ++pushed);
553
554 for (int i=0; i<array_size(s)-1; i++) {
555 lj.srcid = s[i]->id;
556 lj.destid = s[i+1]->id;
557
558 lua_pushjump(L, lj); /* value. */
559 lua_rawseti(L, -2, ++pushed);
560 }
561 array_free(s);
562
563 return 1;
564}
565
576static int systemL_adjacent( lua_State *L )
577{
578 int id, h;
579 StarSystem *s;
580
581 id = 1;
582 s = luaL_validsystem(L,1);
583 h = lua_toboolean(L,2);
584
585 /* Push all adjacent systems. */
586 lua_newtable(L);
587 for (int i=0; i<array_size(s->jumps); i++) {
588 LuaSystem sysp;
589 if (jp_isFlag(&s->jumps[i], JP_EXITONLY ))
590 continue;
591 if (!h && jp_isFlag(&s->jumps[i], JP_HIDDEN))
592 continue;
593 sysp = system_index( s->jumps[i].target );
594 lua_pushsystem(L, sysp); /* value. */
595 lua_rawseti(L,-2,id++);
596 }
597
598 return 1;
599}
600
611static int systemL_jumps( lua_State *L )
612{
613 int exitonly, pushed;
614 StarSystem *s;
615
616 s = luaL_validsystem(L,1);
617 exitonly = lua_toboolean(L,2);
618 pushed = 0;
619
620 /* Push all jumps. */
621 lua_newtable(L);
622 for (int i=0; i<array_size(s->jumps); i++) {
623 LuaJump lj;
624 /* Skip exit-only jumps if requested. */
625 if ((exitonly) && (jp_isFlag( &s->jumps[i], JP_EXITONLY)))
626 continue;
627
628 lj.srcid = s->id;
629 lj.destid = s->jumps[i].targetid;
630 lua_pushjump(L,lj); /* value. */
631 lua_rawseti(L,-2, ++pushed);
632 }
633
634 return 1;
635}
636
646static int systemL_asteroidFields( lua_State *L )
647{
648 StarSystem *s = luaL_validsystem(L,1);
649 /* Push all jumps. */
650 lua_newtable(L);
651 for (int i=0; i<array_size(s->asteroids); i++) {
652 lua_newtable(L);
653
654 lua_pushinteger(L,i+1);
655 lua_setfield(L,-2,"id");
656
657 lua_pushvector(L,s->asteroids[i].pos);
658 lua_setfield(L,-2,"pos");
659
660 lua_pushnumber(L,s->asteroids[i].density);
661 lua_setfield(L,-2,"density");
662
663 lua_pushnumber(L,s->asteroids[i].radius);
664 lua_setfield(L,-2,"radius");
665
666 lua_rawseti(L,-2,i+1);
667 }
668 return 1;
669}
670
685static int systemL_addGatherable( lua_State *L )
686{
687 int nb;
688 unsigned int player_only;
689 Commodity *commodity;
690 vec2 *pos, *vel;
691 vec2 zero = { .x = 0., .y = 0., .mod = 0., .angle = 0. };
692 double lifelength;
693
694 /* Handle parameters. */
695 commodity = luaL_validcommodity( L, 1 );
696 nb = luaL_checkint(L,2);
697 pos = luaL_optvector(L,3,&zero);
698 vel = luaL_optvector(L,4,&zero);
699 lifelength = luaL_optnumber(L,5, -1.); /* -1. means random life length. */
700 player_only = lua_toboolean(L,6);
701
702 lua_pushnumber( L, gatherable_init( commodity, *pos, *vel, lifelength, nb, player_only ) );
703 return 1;
704}
705
718static int systemL_presences( lua_State *L )
719{
720 StarSystem *s = luaL_validsystem(L,1);
721 /* Return result in table */
722 lua_newtable(L);
723 for (int i=0; i<array_size(s->presence); i++) {
724 /* Only return positive presences. */
725 if (s->presence[i].value <= 0)
726 continue;
727
728 lua_pushstring( L, faction_name(s->presence[i].faction) ); /* t, k */
729 lua_pushnumber(L,s->presence[i].value); /* t, k, v */
730 lua_settable(L,-3); /* t */
731 /* allows syntax foo = system.presences(); if foo["bar"] then ... end */
732 }
733 return 1;
734}
735
746static int systemL_spobs( lua_State *L )
747{
748 StarSystem *s = luaL_validsystem(L,1);
749 /* Push all spobs. */
750 lua_newtable(L);
751 for (int i=0; i<array_size(s->spobs); i++) {
752 lua_pushspob(L,spob_index( s->spobs[i] )); /* value */
753 lua_rawseti(L,-2,i+1);
754 }
755 return 1;
756}
757
775static int systemL_presence( lua_State *L )
776{
777 StarSystem *sys;
778 int *fct;
779 double presence;
780 int used;
781
782 /* Get parameters. */
783 sys = luaL_validsystem(L, 1);
784
785 /* Allow fall-through. */
786 used = 0;
787 fct = NULL;
788
789 /* Get the second parameter. */
790 if (lua_isstring(L, 2)) {
791 /* A string command has been given. */
792 const char *cmd = lua_tostring(L, 2);
793 used = 1;
794
795 /* Check the command string and get the appropriate faction group.*/
796 if (strcmp(cmd, "all") == 0)
797 fct = faction_getGroup(0);
798 else if (strcmp(cmd, "friendly") == 0)
799 fct = faction_getGroup(1);
800 else if (strcmp(cmd, "hostile") == 0)
801 fct = faction_getGroup(3);
802 else if (strcmp(cmd, "neutral") == 0)
803 fct = faction_getGroup(2);
804 else /* Invalid command string. */
805 used = 0;
806 }
807
808 if (!used) {
809 /* A faction id was given. */
810 int f = luaL_validfaction(L, 2);
811 fct = array_create(int);
812 array_push_back(&fct, f);
813 }
814
815 /* Add up the presence values. */
816 presence = 0;
817 for (int i=0; i<array_size(fct); i++) {
818 /* Only count positive presences. */
819 double v = system_getPresence( sys, fct[i] );
820 if (v > 0)
821 presence += v;
822 }
823
824 /* Clean up after ourselves. */
825 array_free(fct);
826
827 /* Push it back to Lua. */
828 lua_pushnumber(L, presence);
829 return 1;
830}
831
843static int systemL_radius( lua_State *L )
844{
845 StarSystem *sys = luaL_validsystem(L, 1);
846 lua_pushnumber( L, sys->radius );
847 return 1;
848}
849
859static int systemL_isknown( lua_State *L )
860{
861 StarSystem *sys = luaL_validsystem(L, 1);
862 lua_pushboolean(L, sys_isKnown(sys));
863 return 1;
864}
865
875static int systemL_setknown( lua_State *L )
876{
877 int b, r;
878 StarSystem *sys;
879
880 r = 0;
881 sys = luaL_validsystem(L, 1);
882 b = lua_toboolean(L, 2);
883 if (lua_gettop(L) > 2)
884 r = lua_toboolean(L, 3);
885
886 if (b)
887 sys_setFlag( sys, SYSTEM_KNOWN );
888 else
889 sys_rmFlag( sys, SYSTEM_KNOWN );
890
891 if (r) {
892 if (b) {
893 for (int i=0; i < array_size(sys->spobs); i++)
894 spob_setKnown( sys->spobs[i] );
895 for (int i=0; i < array_size(sys->jumps); i++)
896 jp_setFlag( &sys->jumps[i], JP_KNOWN );
897 }
898 else {
899 for (int i=0; i < array_size(sys->spobs); i++)
900 spob_rmFlag( sys->spobs[i], SPOB_KNOWN );
901 for (int i=0; i < array_size(sys->jumps); i++)
902 jp_rmFlag( &sys->jumps[i], JP_KNOWN );
903 }
904 }
905
906 /* Update outfits image array. */
908 ovr_refresh(); /* Update overlay as necessary. */
909
910 return 0;
911}
912
922static int systemL_hidden( lua_State *L )
923{
924 StarSystem *sys = luaL_validsystem(L, 1);
925 lua_pushboolean(L, sys_isFlag( sys, SYSTEM_HIDDEN ));
926 return 1;
927}
928
938static int systemL_setHidden( lua_State *L )
939{
940 StarSystem *sys = luaL_validsystem(L, 1);
941 int b = lua_toboolean(L,2);
942 if (b)
943 sys_setFlag( sys, SYSTEM_HIDDEN );
944 else
945 sys_rmFlag( sys, SYSTEM_HIDDEN );
946 return 0;
947}
948
958static int systemL_markerClear( lua_State *L )
959{
960 (void) L;
961 ovr_mrkClear();
962 return 0;
963}
964
976static int systemL_markerAdd( lua_State *L )
977{
978 const char *str;
979 vec2 *vec;
980 unsigned int id;
981 double r;
982
983 /* Handle parameters. */
984 vec = luaL_checkvector( L, 1 );
985 str = luaL_optstring( L, 2, NULL );
986 r = luaL_optnumber( L, 3, -1. );
987
988 /* Create marker. */
989 if (r < 0.)
990 id = ovr_mrkAddPoint( str, vec->x, vec->y );
991 else
992 id = ovr_mrkAddCircle( str, vec->x, vec->y, r );
993 lua_pushnumber( L, id );
994 return 1;
995}
996
1005static int systemL_markerRm( lua_State *L )
1006{
1007 unsigned int id = luaL_checklong( L, 1 );
1008 ovr_mrkRm( id );
1009 return 0;
1010}
1011
1021static int systemL_tags( lua_State *L )
1022{
1023 StarSystem *s = luaL_validsystem(L,1);
1024 lua_newtable(L);
1025 for (int i=0; i<array_size(s->tags); i++) {
1026 lua_pushstring(L,s->tags[i]);
1027 lua_pushboolean(L,1);
1028 lua_rawset(L,-3);
1029 }
1030 return 1;
1031}
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
Definition: array.h:158
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
Definition: array.h:168
#define array_push_back(ptr_array, element)
Adds a new element at the end of the array.
Definition: array.h:129
#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:1801
const char * faction_name(int f)
Gets a factions "real" (internal) name.
Definition: faction.c:304
int gatherable_init(const Commodity *com, vec2 pos, vec2 vel, double lifeleng, int qtt, unsigned int player_only)
Initializes a gatherable object.
Definition: gatherable.c:52
void outfits_updateEquipmentOutfits(void)
Updates the outfitter and equipment outfit image arrays.
Definition: land_outfits.c:523
Header file with generic functions and naev-specifics.
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.
Definition: nlua_faction.c:192
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.
Definition: nlua_faction.c:177
LuaJump * lua_pushjump(lua_State *L, LuaJump jump)
Pushes a jump on the stack.
Definition: nlua_jump.c:182
LuaSpob * lua_pushspob(lua_State *L, LuaSpob spob)
Pushes a spob on the stack.
Definition: nlua_spob.c:192
Spob * luaL_validspob(lua_State *L, int ind)
Gets a spob directly.
Definition: nlua_spob.c:164
int lua_isspob(lua_State *L, int ind)
Checks to see if ind is a spob.
Definition: nlua_spob.c:207
static int systemL_name(lua_State *L)
Returns the system's translated name.
Definition: nlua_system.c:330
static int systemL_adjacent(lua_State *L)
Gets all the adjacent systems to a system.
Definition: nlua_system.c:576
static int systemL_position(lua_State *L)
Returns the position of the system.
Definition: nlua_system.c:344
static int systemL_eq(lua_State *L)
Check systems for equality.
Definition: nlua_system.c:305
LuaSystem luaL_checksystem(lua_State *L, int ind)
Gets system at index raising an error if type doesn't match.
Definition: nlua_system.c:141
static int systemL_faction(lua_State *L)
Gets system faction.
Definition: nlua_system.c:378
static int systemL_markerClear(lua_State *L)
Clears the system markers.
Definition: nlua_system.c:958
static int systemL_markerAdd(lua_State *L)
Adds a system marker.
Definition: nlua_system.c:976
int nlua_loadSystem(nlua_env env)
Loads the system library.
Definition: nlua_system.c:104
LuaSystem * lua_pushsystem(lua_State *L, LuaSystem sys)
Pushes a system on the stack.
Definition: nlua_system.c:185
static int systemL_presence(lua_State *L)
Gets the presence in the system.
Definition: nlua_system.c:775
static int systemL_jumpPath(lua_State *L)
Gets jump path from current system, or to another.
Definition: nlua_system.c:522
static int systemL_interference(lua_State *L)
Gets the system's interference level.
Definition: nlua_system.c:432
static int systemL_addGatherable(lua_State *L)
Adds a gatherable object.
Definition: nlua_system.c:685
static int systemL_setHidden(lua_State *L)
Sets a system to be hidden to the player.
Definition: nlua_system.c:938
static int systemL_markerRm(lua_State *L)
Removes a system marker.
Definition: nlua_system.c:1005
static const luaL_Reg system_methods[]
Definition: nlua_system.c:64
static int systemL_asteroidFields(lua_State *L)
Gets all the asteroid fields in a system.
Definition: nlua_system.c:646
static int systemL_hidden(lua_State *L)
Checks to see if a system is hidden by the player.
Definition: nlua_system.c:922
static int systemL_background(lua_State *L)
Gets system background.
Definition: nlua_system.c:395
static int systemL_nebula(lua_State *L)
Gets the system's nebula parameters.
Definition: nlua_system.c:416
static int systemL_tags(lua_State *L)
Gets the system tags.
Definition: nlua_system.c:1021
StarSystem * luaL_validsystem(lua_State *L, int ind)
Gets system (or system name) at index raising an error if type doesn't match.
Definition: nlua_system.c:156
static int systemL_jumps(lua_State *L)
Gets all the jumps in a system.
Definition: nlua_system.c:611
static int systemL_presences(lua_State *L)
Returns the factions that have presence in a system and their respective presence values....
Definition: nlua_system.c:718
static int systemL_isknown(lua_State *L)
Checks to see if a system is known by the player.
Definition: nlua_system.c:859
static int systemL_spobs(lua_State *L)
Gets the spobs in a system.
Definition: nlua_system.c:746
static int systemL_jumpdistance(lua_State *L)
Gets jump distance from current system, or to another.
Definition: nlua_system.c:458
LuaSystem lua_tosystem(lua_State *L, int ind)
Lua system module.
Definition: nlua_system.c:130
static int systemL_cur(lua_State *L)
Gets the current system.
Definition: nlua_system.c:225
static int systemL_setknown(lua_State *L)
Sets a system's known state.
Definition: nlua_system.c:875
static int systemL_get(lua_State *L)
Gets a system.
Definition: nlua_system.c:245
static int systemL_getAll(lua_State *L)
Gets all the systems. Lua return parameter: {System,...} A list of all the systems.
Definition: nlua_system.c:282
static int systemL_radius(lua_State *L)
Gets the radius of the system.
Definition: nlua_system.c:843
static int systemL_nameRaw(lua_State *L)
Returns the system's raw (untranslated) name.
Definition: nlua_system.c:364
int lua_issystem(lua_State *L, int ind)
Checks to see if ind is a system.
Definition: nlua_system.c:201
vec2 * luaL_checkvector(lua_State *L, int ind)
Gets vector at index making sure type is valid.
Definition: nlua_vec2.c:124
vec2 * lua_pushvector(lua_State *L, vec2 vec)
Pushes a vector on the stack.
Definition: nlua_vec2.c:139
static const double a[]
Definition: rng.c:247
static const double b[]
Definition: rng.c:256
StarSystem * system_getIndex(int id)
Get the system by its index.
Definition: space.c:944
int spob_index(const Spob *p)
Gets the ID of a spob.
Definition: space.c:1055
StarSystem * system_getAll(void)
Gets an array (array.h) of all star systems.
Definition: space.c:847
StarSystem * system_get(const char *sysname)
Get the system from its name.
Definition: space.c:914
char * spob_getSystem(const char *spobname)
Get the name of a system from a spobname.
Definition: space.c:980
void spob_setKnown(Spob *p)
Sets a spob's known status, if it's real.
Definition: space.c:1071
StarSystem * cur_system
Definition: space.c:105
double system_getPresence(const StarSystem *sys, int faction)
Get the presence of a faction in a system.
Definition: space.c:4138
int system_index(const StarSystem *sys)
Gets the index of a star system.
Definition: space.c:955
Represents a commodity.
Definition: commodity.h:43
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:88
char * name
Definition: space.h:90
Represents a 2d vector.
Definition: vec2.h:32
double y
Definition: vec2.h:34
double x
Definition: vec2.h:33