naev 0.11.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>
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 StarSystem *s;
159
160 if (lua_issystem(L, ind)) {
161 LuaSystem ls = luaL_checksystem(L, ind);
162 s = system_getIndex( ls );
163 }
164 else if (lua_isstring(L, ind))
165 s = system_get( lua_tostring(L, ind) );
166 else {
167 luaL_typerror(L, ind, SYSTEM_METATABLE);
168 return NULL;
169 }
170
171 if (s == NULL)
172 NLUA_ERROR(L, _("System is invalid"));
173
174 return s;
175}
176
184LuaSystem* lua_pushsystem( lua_State *L, LuaSystem sys )
185{
186 LuaSystem *s = (LuaSystem*) lua_newuserdata(L, sizeof(LuaSystem));
187 *s = sys;
188 luaL_getmetatable(L, SYSTEM_METATABLE);
189 lua_setmetatable(L, -2);
190 return s;
191}
192
200int lua_issystem( lua_State *L, int ind )
201{
202 int ret;
203
204 if (lua_getmetatable(L,ind)==0)
205 return 0;
206 lua_getfield(L, LUA_REGISTRYINDEX, SYSTEM_METATABLE);
207
208 ret = 0;
209 if (lua_rawequal(L, -1, -2)) /* does it have the correct mt? */
210 ret = 1;
211
212 lua_pop(L, 2); /* remove both metatables */
213 return ret;
214}
215
224static int systemL_cur( lua_State *L )
225{
227 return 1;
228}
229
244static int systemL_get( lua_State *L )
245{
246 StarSystem *ss;
247 Spob *pnt;
248
249 /* Passing a string (systemname) */
250 if (lua_isstring(L,1)) {
251 ss = system_get( lua_tostring(L,1) );
252 }
253 /* Passing a spob */
254 else if (lua_isspob(L,1)) {
255 pnt = luaL_validspob(L,1);
256 ss = system_get( spob_getSystem( pnt->name ) );
257 }
258 else if (lua_issystem(L,1)) {
259 lua_pushvalue(L,1);
260 return 1;
261 }
262 else
263 NLUA_INVALID_PARAMETER(L,1);
264
265 /* Error checking. */
266 if (ss == NULL)
267 return NLUA_ERROR(L, _("No matching systems found."));
268
269 /* return the system */
271 return 1;
272}
273
279static int systemL_getAll( lua_State *L )
280{
281 StarSystem *sys = system_getAll();
282 lua_newtable(L);
283 for (int i=0; i<array_size(sys); i++) {
284 lua_pushsystem( L, system_index( &sys[i] ) );
285 lua_rawseti( L, -2, i+1 );
286 }
287 return 1;
288}
289
302static int systemL_eq( lua_State *L )
303{
304 LuaSystem a, b;
305 a = luaL_checksystem(L,1);
306 b = luaL_checksystem(L,2);
307 if (a == b)
308 lua_pushboolean(L,1);
309 else
310 lua_pushboolean(L,0);
311 return 1;
312}
313
327static int systemL_name( lua_State *L )
328{
329 const StarSystem *sys = luaL_validsystem(L,1);
330 lua_pushstring(L, _(sys->name));
331 return 1;
332}
333
341static int systemL_position( lua_State *L )
342{
343 const StarSystem *sys = luaL_validsystem(L,1);
344 lua_pushvector(L, sys->pos);
345 return 1;
346}
347
361static int systemL_nameRaw( lua_State *L )
362{
363 StarSystem *sys = luaL_validsystem(L,1);
364 lua_pushstring(L, sys->name);
365 return 1;
366}
367
375static int systemL_faction( lua_State *L )
376{
377 const StarSystem *s = luaL_validsystem(L,1);
378 if (s->faction == -1)
379 return 0;
380 lua_pushfaction(L,s->faction);
381 return 1;
382
383}
384
392static int systemL_background( lua_State *L )
393{
394 StarSystem *s = luaL_validsystem(L,1);
395 if (s->background==NULL)
396 return 0;
397 lua_pushstring(L,s->background);
398 return 1;
399
400}
401
412static int systemL_nebula( lua_State *L )
413{
414 StarSystem *s = luaL_validsystem(L,1);
415 /* Push the density and volatility. */
416 lua_pushnumber(L, s->nebu_density);
417 lua_pushnumber(L, s->nebu_volatility);
418 return 2;
419}
420
428static int systemL_interference( lua_State *L )
429{
430 StarSystem *s = luaL_validsystem(L,1);
431 lua_pushnumber( L, s->interference );
432 return 1;
433}
434
454static int systemL_jumpdistance( lua_State *L )
455{
456 StarSystem *sys;
457 StarSystem **s;
458 const char *start, *goal;
459 int h, k;
460
461 sys = luaL_validsystem(L,1);
462 start = sys->name;
463 h = lua_toboolean(L,3);
464 k = !lua_toboolean(L,4);
465
466 if (lua_gettop(L) > 1) {
467 if (lua_isstring(L,2))
468 goal = lua_tostring(L,2);
469 else if (lua_issystem(L,2)) {
470 const StarSystem *sysp = luaL_validsystem(L,2);
471 goal = sysp->name;
472 }
473 else
474 NLUA_INVALID_PARAMETER(L,2);
475 }
476 else {
477 goal = sys->name;
478 start = cur_system->name;
479 }
480
481 /* Trivial case same system. */
482 if (strcmp(start,goal)==0) {
483 lua_pushnumber(L, 0.);
484 return 1;
485 }
486
487 s = map_getJumpPath( start, NULL, goal, k, h, NULL, NULL );
488 if (s==NULL) {
489 lua_pushnumber(L, HUGE_VAL);
490 return 1;
491 }
492
493 lua_pushnumber(L,array_size(s));
494 array_free(s);
495 return 1;
496}
497
518static int systemL_jumpPath( lua_State *L )
519{
520 LuaJump lj;
521 StarSystem *sys, *sysp;
522 StarSystem **s;
523 int sid, pushed, h;
524 const char *start, *goal;
525
526 h = lua_toboolean(L,3);
527
528 /* Foo to Bar */
529 sys = luaL_validsystem(L,1);
530 start = sys->name;
531 sid = sys->id;
532 sysp = luaL_validsystem(L,2);
533 goal = sysp->name;
534
535 s = map_getJumpPath( start, NULL, goal, 1, h, NULL, NULL );
536 if (s == NULL)
537 return 0;
538
539 /* Create the jump table. */
540 lua_newtable(L);
541 pushed = 0;
542
543 /* Map path doesn't contain the start system, push it manually. */
544 lj.srcid = sid;
545 lj.destid = s[0]->id;
546
547 lua_pushjump(L, lj); /* value. */
548 lua_rawseti(L, -2, ++pushed);
549
550 for (int i=0; i<array_size(s)-1; i++) {
551 lj.srcid = s[i]->id;
552 lj.destid = s[i+1]->id;
553
554 lua_pushjump(L, lj); /* value. */
555 lua_rawseti(L, -2, ++pushed);
556 }
557 array_free(s);
558
559 return 1;
560}
561
572static int systemL_adjacent( lua_State *L )
573{
574 int id, h;
575 StarSystem *s;
576
577 id = 1;
578 s = luaL_validsystem(L,1);
579 h = lua_toboolean(L,2);
580
581 /* Push all adjacent systems. */
582 lua_newtable(L);
583 for (int i=0; i<array_size(s->jumps); i++) {
584 LuaSystem sysp;
585 if (jp_isFlag(&s->jumps[i], JP_EXITONLY ))
586 continue;
587 if (!h && jp_isFlag(&s->jumps[i], JP_HIDDEN))
588 continue;
589 sysp = system_index( s->jumps[i].target );
590 lua_pushsystem(L, sysp); /* value. */
591 lua_rawseti(L,-2,id++);
592 }
593
594 return 1;
595}
596
607static int systemL_jumps( lua_State *L )
608{
609 StarSystem *s = luaL_validsystem(L,1);
610 int exitonly = lua_toboolean(L,2);
611 int pushed = 0;
612
613 /* Push all jumps. */
614 lua_newtable(L);
615 for (int i=0; i<array_size(s->jumps); i++) {
616 LuaJump lj;
617 /* Skip exit-only jumps if requested. */
618 if ((exitonly) && (jp_isFlag( &s->jumps[i], JP_EXITONLY)))
619 continue;
620
621 lj.srcid = s->id;
622 lj.destid = s->jumps[i].targetid;
623 lua_pushjump(L,lj); /* value. */
624 lua_rawseti(L,-2, ++pushed);
625 }
626
627 return 1;
628}
629
639static int systemL_asteroidFields( lua_State *L )
640{
641 StarSystem *s = luaL_validsystem(L,1);
642 /* Push all jumps. */
643 lua_newtable(L);
644 for (int i=0; i<array_size(s->asteroids); i++) {
645 lua_newtable(L);
646
647 lua_pushinteger(L,i+1);
648 lua_setfield(L,-2,"id");
649
650 lua_pushvector(L,s->asteroids[i].pos);
651 lua_setfield(L,-2,"pos");
652
653 lua_pushnumber(L,s->asteroids[i].density);
654 lua_setfield(L,-2,"density");
655
656 lua_pushnumber(L,s->asteroids[i].radius);
657 lua_setfield(L,-2,"radius");
658
659 lua_rawseti(L,-2,i+1);
660 }
661 return 1;
662}
663
678static int systemL_addGatherable( lua_State *L )
679{
680 int nb;
681 unsigned int player_only;
682 Commodity *commodity;
683 vec2 *pos, *vel;
684 vec2 zero = { .x = 0., .y = 0., .mod = 0., .angle = 0. };
685 double lifelength;
686
687 /* Handle parameters. */
688 commodity = luaL_validcommodity( L, 1 );
689 nb = luaL_checkint(L,2);
690 pos = luaL_optvector(L,3,&zero);
691 vel = luaL_optvector(L,4,&zero);
692 lifelength = luaL_optnumber(L,5, -1.); /* -1. means random life length. */
693 player_only = lua_toboolean(L,6);
694
695 lua_pushnumber( L, gatherable_init( commodity, pos, vel, lifelength, nb, player_only ) );
696 return 1;
697}
698
711static int systemL_presences( lua_State *L )
712{
713 StarSystem *s = luaL_validsystem(L,1);
714 /* Return result in table */
715 lua_newtable(L);
716 for (int i=0; i<array_size(s->presence); i++) {
717 /* Only return positive presences. */
718 if (s->presence[i].value <= 0)
719 continue;
720
721 lua_pushstring( L, faction_name(s->presence[i].faction) ); /* t, k */
722 lua_pushnumber(L,s->presence[i].value); /* t, k, v */
723 lua_settable(L,-3); /* t */
724 /* allows syntax foo = system.presences(); if foo["bar"] then ... end */
725 }
726 return 1;
727}
728
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
768static int systemL_presence( lua_State *L )
769{
770 StarSystem *sys;
771 int *fct;
772 double presence;
773 int used;
774
775 /* Get parameters. */
776 sys = luaL_validsystem(L, 1);
777
778 /* Allow fall-through. */
779 used = 0;
780 fct = NULL;
781
782 /* Get the second parameter. */
783 if (lua_isstring(L, 2)) {
784 /* A string command has been given. */
785 const char *cmd = lua_tostring(L, 2);
786 used = 1;
787
788 /* Check the command string and get the appropriate faction group.*/
789 if (strcmp(cmd, "all") == 0)
790 fct = faction_getGroup(0);
791 else if (strcmp(cmd, "friendly") == 0)
792 fct = faction_getGroup(1);
793 else if (strcmp(cmd, "hostile") == 0)
794 fct = faction_getGroup(3);
795 else if (strcmp(cmd, "neutral") == 0)
796 fct = faction_getGroup(2);
797 else /* Invalid command string. */
798 used = 0;
799 }
800
801 if (!used) {
802 /* A faction id was given. */
803 int f = luaL_validfaction(L, 2);
804 fct = array_create(int);
805 array_push_back(&fct, f);
806 }
807
808 /* Add up the presence values. */
809 presence = 0;
810 for (int i=0; i<array_size(fct); i++) {
811 /* Only count positive presences. */
812 double v = system_getPresence( sys, fct[i] );
813 if (v > 0)
814 presence += v;
815 }
816
817 /* Clean up after ourselves. */
818 array_free(fct);
819
820 /* Push it back to Lua. */
821 lua_pushnumber(L, presence);
822 return 1;
823}
824
836static int systemL_radius( lua_State *L )
837{
838 StarSystem *sys = luaL_validsystem(L, 1);
839 lua_pushnumber( L, sys->radius );
840 return 1;
841}
842
852static int systemL_isknown( lua_State *L )
853{
854 const StarSystem *sys = luaL_validsystem(L, 1);
855 lua_pushboolean(L, sys_isKnown(sys));
856 return 1;
857}
858
868static int systemL_setknown( lua_State *L )
869{
870 int b, r;
871 StarSystem *sys;
872
873 r = 0;
874 sys = luaL_validsystem(L, 1);
875 b = lua_toboolean(L, 2);
876 if (lua_gettop(L) > 2)
877 r = lua_toboolean(L, 3);
878
879 if (b)
880 sys_setFlag( sys, SYSTEM_KNOWN );
881 else
882 sys_rmFlag( sys, SYSTEM_KNOWN );
883
884 if (r) {
885 if (b) {
886 for (int i=0; i < array_size(sys->spobs); i++)
887 spob_setKnown( sys->spobs[i] );
888 for (int i=0; i < array_size(sys->jumps); i++)
889 jp_setFlag( &sys->jumps[i], JP_KNOWN );
890 }
891 else {
892 for (int i=0; i < array_size(sys->spobs); i++)
893 spob_rmFlag( sys->spobs[i], SPOB_KNOWN );
894 for (int i=0; i < array_size(sys->jumps); i++)
895 jp_rmFlag( &sys->jumps[i], JP_KNOWN );
896 }
897 }
898
899 /* Update outfits image array. */
901 ovr_refresh(); /* Update overlay as necessary. */
902
903 return 0;
904}
905
915static int systemL_hidden( lua_State *L )
916{
917 const StarSystem *sys = luaL_validsystem(L, 1);
918 lua_pushboolean(L, sys_isFlag( sys, SYSTEM_HIDDEN ));
919 return 1;
920}
921
931static int systemL_setHidden( lua_State *L )
932{
933 StarSystem *sys = luaL_validsystem(L, 1);
934 int b = lua_toboolean(L,2);
935 if (b)
936 sys_setFlag( sys, SYSTEM_HIDDEN );
937 else
938 sys_rmFlag( sys, SYSTEM_HIDDEN );
939 return 0;
940}
941
951static int systemL_markerClear( lua_State *L )
952{
953 (void) L;
954 ovr_mrkClear();
955 return 0;
956}
957
969static int systemL_markerAdd( lua_State *L )
970{
971 const char *str;
972 vec2 *vec;
973 unsigned int id;
974 double r;
975
976 /* Handle parameters. */
977 vec = luaL_checkvector( L, 1 );
978 str = luaL_optstring( L, 2, NULL );
979 r = luaL_optnumber( L, 3, -1. );
980
981 /* Create marker. */
982 if (r < 0.)
983 id = ovr_mrkAddPoint( str, vec->x, vec->y );
984 else
985 id = ovr_mrkAddCircle( str, vec->x, vec->y, r );
986 lua_pushnumber( L, id );
987 return 1;
988}
989
998static int systemL_markerRm( lua_State *L )
999{
1000 unsigned int id = luaL_checklong( L, 1 );
1001 ovr_mrkRm( id );
1002 return 0;
1003}
1004
1014static int systemL_tags( lua_State *L )
1015{
1016 StarSystem *s = luaL_validsystem(L,1);
1017 lua_newtable(L);
1018 for (int i=0; i<array_size(s->tags); i++) {
1019 lua_pushstring(L,s->tags[i]);
1020 lua_pushboolean(L,1);
1021 lua_rawset(L,-3);
1022 }
1023 return 1;
1024}
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:1836
const char * faction_name(int f)
Gets a factions "real" (internal) name.
Definition faction.c:306
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:66
void outfits_updateEquipmentOutfits(void)
Updates the outfitter and equipment outfit image arrays.
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.
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:185
LuaSpob * lua_pushspob(lua_State *L, LuaSpob spob)
Pushes a spob on the stack.
Definition nlua_spob.c:201
Spob * luaL_validspob(lua_State *L, int ind)
Gets a spob directly.
Definition nlua_spob.c:174
int lua_isspob(lua_State *L, int ind)
Checks to see if ind is a spob.
Definition nlua_spob.c:216
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_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 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.
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:989
int spob_index(const Spob *p)
Gets the ID of a spob.
Definition space.c:1099
StarSystem * system_getAll(void)
Gets an array (array.h) of all star systems.
Definition space.c:879
StarSystem * system_get(const char *sysname)
Get the system from its name.
Definition space.c:960
const char * spob_getSystem(const char *spobname)
Get the name of a system from a spobname.
Definition space.c:1025
void spob_setKnown(Spob *p)
Sets a spob's known status, if it's real.
Definition space.c:1115
StarSystem * cur_system
Definition space.c:106
double system_getPresence(const StarSystem *sys, int faction)
Get the presence of a faction in a system.
Definition space.c:4181
int system_index(const StarSystem *sys)
Gets the index of a star system.
Definition space.c:1000
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:89
char * name
Definition space.h:91
Represents a 2d vector.
Definition vec2.h:32
double y
Definition vec2.h:34
double x
Definition vec2.h:33