naev 0.11.5
nlua_spob.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
10#include "naev.h"
11
12#include <lauxlib.h>
15#include "nlua_spob.h"
16
17#include "array.h"
18#include "land.h"
19#include "land_outfits.h"
20#include "log.h"
21#include "map.h"
22#include "map_overlay.h"
23#include "nlua_colour.h"
24#include "nlua_commodity.h"
25#include "nlua_faction.h"
26#include "nlua_outfit.h"
27#include "nlua_ship.h"
28#include "nlua_system.h"
29#include "nlua_tex.h"
30#include "nlua_time.h"
31#include "nlua_vec2.h"
32#include "nluadef.h"
33#include "nmath.h"
34#include "nstring.h"
35#include "rng.h"
36
37/* Spob metatable methods */
38static int spobL_cur( lua_State *L );
39static int spobL_get( lua_State *L );
40static int spobL_getS( lua_State *L );
41static int spobL_getLandable( lua_State *L );
42static int spobL_getAll( lua_State *L );
43static int spobL_system( lua_State *L );
44static int spobL_eq( lua_State *L );
45static int spobL_name( lua_State *L );
46static int spobL_nameRaw( lua_State *L );
47static int spobL_population( lua_State *L );
48static int spobL_radius( lua_State *L );
49static int spobL_faction( lua_State *L );
50static int spobL_colour( lua_State *L );
51static int spobL_colourChar( lua_State *L );
52static int spobL_class( lua_State *L );
53static int spobL_classLong( lua_State *L );
54static int spobL_position( lua_State *L );
55static int spobL_services( lua_State *L );
56static int spobL_flags( lua_State *L );
57static int spobL_canland( lua_State *L );
58static int spobL_landAllow( lua_State *L );
59static int spobL_landDeny( lua_State *L );
60static int spobL_getLandAllow( lua_State *L );
61static int spobL_getLandDeny( lua_State *L );
62static int spobL_gfxSpace( lua_State *L );
63static int spobL_gfxExterior( lua_State *L );
64static int spobL_gfxExteriorPath( lua_State *L );
65static int spobL_gfxComm( lua_State *L );
66static int spobL_shipsSold( lua_State *L );
67static int spobL_outfitsSold( lua_State *L );
68static int spobL_commoditiesSold( lua_State *L );
69static int spobL_isBlackMarket( lua_State *L );
70static int spobL_isKnown( lua_State *L );
71static int spobL_setKnown( lua_State *L );
72static int spobL_recordCommodityPriceAtTime( lua_State *L );
73static int spobL_tags( lua_State *L );
74static const luaL_Reg spob_methods[] = {
75 { "cur", spobL_cur },
76 { "get", spobL_get },
77 { "getS", spobL_getS },
78 { "getLandable", spobL_getLandable },
79 { "getAll", spobL_getAll },
80 { "system", spobL_system },
81 { "__eq", spobL_eq },
82 { "__tostring", spobL_name },
83 { "name", spobL_name },
84 { "nameRaw", spobL_nameRaw },
85 { "population", spobL_population },
86 { "radius", spobL_radius },
87 { "faction", spobL_faction },
88 { "colour", spobL_colour },
89 { "colourChar", spobL_colourChar },
90 { "class", spobL_class },
91 { "classLong", spobL_classLong },
92 { "pos", spobL_position },
93 { "services", spobL_services },
94 { "flags", spobL_flags },
95 { "canLand", spobL_canland },
96 { "landAllow", spobL_landAllow },
97 { "landDeny", spobL_landDeny },
98 { "getLandAllow", spobL_getLandAllow },
99 { "getLandDeny", spobL_getLandDeny },
100 { "gfxSpace", spobL_gfxSpace },
101 { "gfxExterior", spobL_gfxExterior },
102 { "gfxExteriorPath", spobL_gfxExteriorPath },
103 { "gfxComm", spobL_gfxComm },
104 { "shipsSold", spobL_shipsSold },
105 { "outfitsSold", spobL_outfitsSold },
106 { "commoditiesSold", spobL_commoditiesSold },
107 { "blackmarket", spobL_isBlackMarket },
108 { "known", spobL_isKnown },
109 { "setKnown", spobL_setKnown },
110 { "recordCommodityPriceAtTime", spobL_recordCommodityPriceAtTime },
111 { "tags", spobL_tags },
112 {0,0}
113};
121int nlua_loadSpob( nlua_env env )
122{
123 nlua_register(env, SPOB_METATABLE, spob_methods, 1);
124 return 0; /* No error */
125}
126
149LuaSpob lua_tospob( lua_State *L, int ind )
150{
151 return *((LuaSpob*) lua_touserdata(L,ind));
152}
160LuaSpob luaL_checkspob( lua_State *L, int ind )
161{
162 if (lua_isspob(L,ind))
163 return lua_tospob(L,ind);
164 luaL_typerror(L, ind, SPOB_METATABLE);
165 return 0;
166}
174Spob* luaL_validspob( lua_State *L, int ind )
175{
176 Spob *p;
177
178 if (lua_isspob(L, ind)) {
179 LuaSpob lp = luaL_checkspob(L, ind);
180 p = spob_getIndex(lp);
181 }
182 else if (lua_isstring(L, ind))
183 p = spob_get( lua_tostring(L, ind) );
184 else {
185 luaL_typerror(L, ind, SPOB_METATABLE);
186 return NULL;
187 }
188
189 if (p == NULL)
190 NLUA_ERROR(L, _("Spob is invalid"));
191
192 return p;
193}
201LuaSpob* lua_pushspob( lua_State *L, LuaSpob spob )
202{
203 LuaSpob *p = (LuaSpob*) lua_newuserdata(L, sizeof(LuaSpob));
204 *p = spob;
205 luaL_getmetatable(L, SPOB_METATABLE);
206 lua_setmetatable(L, -2);
207 return p;
208}
216int lua_isspob( lua_State *L, int ind )
217{
218 int ret;
219
220 if (lua_getmetatable(L,ind)==0)
221 return 0;
222 lua_getfield(L, LUA_REGISTRYINDEX, SPOB_METATABLE);
223
224 ret = 0;
225 if (lua_rawequal(L, -1, -2)) /* does it have the correct mt? */
226 ret = 1;
227
228 lua_pop(L, 2); /* remove both metatables */
229 return ret;
230}
231
241static int spobL_cur( lua_State *L )
242{
243 LuaSystem sys;
244 if (land_spob == NULL)
245 return NLUA_ERROR(L,_("Attempting to get landed spob when player not landed."));
248 lua_pushsystem(L,sys);
249 return 2;
250}
251
252static int spobL_getBackend( lua_State *L, int system, int landable )
253{
254 char **spobs;
255 const char *rndspob;
256 Spob *pnt;
257
258 rndspob = NULL;
259 spobs = NULL;
260
261 /* If boolean return random. */
262 if (lua_isboolean(L,1)) {
263 pnt = spob_get( space_getRndSpob(landable, 0, NULL) );
264 rndspob = pnt->name;
265 }
266 /* Get a spob by faction */
267 else if (lua_isfaction(L,1)) {
268 int *factions = array_create( int );
269 array_push_back( &factions, lua_tofaction(L,1) );
270 spobs = space_getFactionSpob( factions, landable );
271 array_free( factions );
272 }
273 /* Get a spob by name */
274 else if (lua_isstring(L,1)) {
275 rndspob = lua_tostring(L,1);
276
277 if (landable) {
278 pnt = spob_get( rndspob );
279 if (pnt == NULL)
280 return NLUA_ERROR(L, _("Spob '%s' not found in stack"), rndspob);
281
282 /* Check if can land. */
283 spob_updateLand( pnt );
284 if (!pnt->can_land)
285 return 0;
286 }
287 }
288 /* Get a spob from faction list */
289 else if (lua_istable(L,1)) {
290 /* Get table length and preallocate. */
291 int *factions = array_create_size( int, lua_objlen(L,1) );
292 /* Load up the table. */
293 lua_pushnil(L);
294 while (lua_next(L, -2) != 0) {
295 if (lua_isfaction(L, -1))
296 array_push_back( &factions, lua_tofaction(L, -1) );
297 lua_pop(L,1);
298 }
299
300 /* get the spobs */
301 spobs = space_getFactionSpob( factions, landable );
302 array_free(factions);
303 }
304 /* Just get a spob. */
305 else if (lua_isspob(L,1)) {
306 pnt = luaL_validspob( L, 1 );
307 if (landable) {
308 /* Check if can land. */
309 spob_updateLand( pnt );
310 if (!pnt->can_land)
311 return 0;
312 }
313 rndspob = pnt->name;
314 }
315 else
316 NLUA_INVALID_PARAMETER(L,1); /* Bad Parameter */
317
318 /* Pick random spob */
319 if (rndspob == NULL) {
320 arrayShuffle( (void**)spobs );
321
322 for (int i=0; i<array_size(spobs); i++) {
323 if (landable) {
324 /* Check landing. */
325 pnt = spob_get( spobs[i] );
326 if (pnt == NULL)
327 continue;
328
329 spob_updateLand( pnt );
330 if (!pnt->can_land)
331 continue;
332 }
333
334 rndspob = spobs[i];
335 break;
336 }
337 }
338 array_free(spobs);
339
340 /* No suitable spob found */
341 if (rndspob == NULL && array_size( spobs ) == 0)
342 return 0;
343
344 /* Push the spob */
345 pnt = spob_get(rndspob); /* The real spob */
346 if (pnt == NULL)
347 return NLUA_ERROR(L, _("Spob '%s' not found in stack"), rndspob);
348 lua_pushspob(L,spob_index( pnt ));
349 if (system) {
350 LuaSystem sys;
351 const char *sysname = spob_getSystem( rndspob );
352 if (sysname == NULL)
353 return 1;
354 sys = system_index( system_get( sysname ) );
355 lua_pushsystem( L, sys );
356 return 2;
357 }
358 return 1;
359}
360
379static int spobL_get( lua_State *L )
380{
381 return spobL_getBackend( L, 0, 0 );
382}
383
403static int spobL_getS( lua_State *L )
404{
405 return spobL_getBackend( L, 1, 0 );
406}
407
419static int spobL_getLandable( lua_State *L )
420{
421 return spobL_getBackend( L, 1, 1 );
422}
423
430static int spobL_getAll( lua_State *L )
431{
432 Spob *p = spob_getAll();
433 int n = 1;
434 int all_spob = lua_toboolean(L,1);
435 lua_newtable(L);
436 for (int i=0; i<array_size(p); i++) {
437 if (!all_spob && !spob_hasSystem(&p[i]))
438 continue;
439 lua_pushspob( L, spob_index( &p[i] ) );
440 lua_rawseti( L, -2, n++ );
441 }
442 return 1;
443}
444
451static int spobL_system( lua_State *L )
452{
453 LuaSystem sys;
454 const Spob *p = luaL_validspob(L,1);
455 const char *sysname = spob_getSystem( p->name );
456 if (sysname == NULL)
457 return 0;
458 sys = system_index( system_get( sysname ) );
459 lua_pushsystem( L, sys );
460 return 1;
461}
462
473static int spobL_eq( lua_State *L )
474{
475 LuaSpob a, b;
476 a = luaL_checkspob(L,1);
477 b = luaL_checkspob(L,2);
478 lua_pushboolean(L,(a == b));
479 return 1;
480}
481
498static int spobL_name( lua_State *L )
499{
500 const Spob *p = luaL_validspob(L,1);
501 lua_pushstring(L, spob_name(p));
502 return 1;
503}
504
517static int spobL_nameRaw( lua_State *L )
518{
519 Spob *p = luaL_validspob(L,1);
520 lua_pushstring(L, p->name);
521 return 1;
522}
523
531static int spobL_population( lua_State *L )
532{
533 Spob *p = luaL_validspob(L,1);
534 lua_pushnumber(L,p->population);
535 return 1;
536}
537
546static int spobL_radius( lua_State *L )
547{
548 Spob *p = luaL_validspob(L,1);
549 /* Ensure graphics measurements are available. */
550 if (p->radius < 0.)
551 spob_gfxLoad(p);
552 lua_pushnumber(L,p->radius);
553 return 1;
554}
555
564static int spobL_faction( lua_State *L )
565{
566 Spob *p = luaL_validspob(L,1);
567 if (p->presence.faction < 0)
568 return 0;
569 lua_pushfaction(L, p->presence.faction);
570 return 1;
571}
572
582static int spobL_colour( lua_State *L )
583{
584 const Spob *p = luaL_validspob(L,1);
585 const glColour *col = spob_getColour( p );
586 lua_pushcolour( L, *col );
587 return 1;
588}
589
599static int spobL_colourChar( lua_State *L )
600{
601 const Spob *p = luaL_validspob(L,1);
602 char str[2];
603 str[0] = spob_getColourChar( p );
604 str[1] = '\0';
605 lua_pushstring( L, str );
606 return 1;
607}
608
620static int spobL_class(lua_State *L )
621{
622 Spob *p = luaL_validspob(L,1);
623 lua_pushstring(L,p->class);
624 return 1;
625}
626
635static int spobL_classLong(lua_State *L )
636{
637 const Spob *p = luaL_validspob(L,1);
638 lua_pushstring(L, spob_getClassName(p->class));
639 return 1;
640}
641
662static int spobL_services( lua_State *L )
663{
664 const Spob *p = luaL_validspob(L,1);
665 /* Return result in table */
666 lua_newtable(L);
667 /* allows syntax like foo = spob.get("foo"); if foo["bar"] then ... end */
668 for (int i=1; i<SPOB_SERVICES_MAX; i<<=1) {
669 if (spob_hasService(p, i)) {
670 char lower[STRMAX_SHORT];
671 const char *name = spob_getServiceName(i);
672 size_t len = strlen(name) + 1;
673 snprintf( lower, MIN(len,sizeof(lower)), "%c%s", tolower(name[0]), &name[1] );
674
675 /* GUI depends on this returning the service name. */
676 lua_pushstring(L, _(name));
677 lua_setfield(L, -2, lower );
678 }
679 }
680 return 1;
681}
682
694static int spobL_flags( lua_State *L )
695{
696 const Spob *p = luaL_validspob(L,1);
697 lua_newtable(L);
698 if (spob_isFlag( p, SPOB_NOMISNSPAWN )) {
699 lua_pushstring(L, "nomissionspawn");
700 lua_pushboolean(L, 1);
701 lua_settable(L,-3);
702 }
703 return 1;
704}
705
714static int spobL_canland( lua_State *L )
715{
716 Spob *p = luaL_validspob(L,1);
717 spob_updateLand( p ); /* Update to make sure it's correct. */
718 lua_pushboolean( L, p->can_land );
719 return 1;
720}
721
722static int landAllowDeny( lua_State *L, int allowdeny )
723{
724 Spob *p = luaL_validspob(L,1);
725 int old = p->land_override;
726 p->land_override = allowdeny * !!lua_toboolean(L,2);
727 /* Set the message as necessary. */
728 free( p->land_msg );
729 p->land_msg = NULL;
730 if (!lua_isnoneornil(L,3))
731 p->land_msg = strdup( luaL_checkstring(L,3) );
732
733 /* If the value has changed, re-run the landing Lua next frame. */
734 if (p->land_override != old)
736 return 0;
737}
738
748static int spobL_landAllow( lua_State *L )
749{
750 return landAllowDeny( L, +1 );
751}
752
762static int spobL_landDeny( lua_State *L )
763{
764 return landAllowDeny( L, -1 );
765}
766
775static int spobL_getLandAllow( lua_State *L )
776{
777 const Spob *p = luaL_validspob(L,1);
778 lua_pushboolean(L, p->land_override>0);
779 return 1;
780}
781
790static int spobL_getLandDeny( lua_State *L )
791{
792 const Spob *p = luaL_validspob(L,1);
793 lua_pushboolean(L, p->land_override<0);
794 return 1;
795}
796
805static int spobL_position( lua_State *L )
806{
807 const Spob *p = luaL_validspob(L,1);
808 lua_pushvector(L, p->pos);
809 return 1;
810}
811
820static int spobL_gfxSpace( lua_State *L )
821{
822 glTexture *tex;
823 const Spob *p = luaL_validspob(L,1);
824 if (p->gfx_space == NULL) { /* Not loaded. */
825 /* If the spob has no texture, just return nothing. */
826 if (p->gfx_spaceName == NULL)
827 return 0;
828 tex = gl_newImage( p->gfx_spaceName, OPENGL_TEX_MIPMAPS );
829 }
830 else
831 tex = gl_dupTexture( p->gfx_space );
832 lua_pushtex( L, tex );
833 return 1;
834}
835
844static int spobL_gfxExterior( lua_State *L )
845{
846 const Spob *p = luaL_validspob(L,1);
847
848 /* If no exterior image just return nothing instead of crashing. */
849 if (p->gfx_exterior==NULL)
850 return 0;
851
852 lua_pushtex( L, gl_newImage( p->gfx_exterior, 0 ) );
853 return 1;
854}
855
863static int spobL_gfxExteriorPath( lua_State *L )
864{
865 const Spob *p = luaL_validspob(L,1);
866 lua_pushstring( L, p->gfx_exteriorPath );
867 return 1;
868}
869
878static int spobL_gfxComm( lua_State *L )
879{
880 const Spob *p = luaL_validspob(L,1);
881 if (p->gfx_comm==NULL)
882 return spobL_gfxSpace(L);
883 lua_pushtex( L, gl_newImage( p->gfx_comm, 0 ) );
884 return 1;
885}
886
894static int spobL_shipsSold( lua_State *L )
895{
896 const Spob *p = luaL_validspob(L,1);
897 Ship **s = tech_getShip( p->tech );
898
899 /* Push results in a table. */
900 lua_newtable(L);
901 for (int i=0; i<array_size(s); i++) {
902 lua_pushship(L,s[i]); /* value = LuaShip */
903 lua_rawseti(L,-2,i+1); /* store the value in the table */
904 }
905
906 array_free(s);
907 return 1;
908}
909
917static int spobL_outfitsSold( lua_State *L )
918{
919 const Spob *p = luaL_validspob(L,1);
920 Outfit **o = tech_getOutfit( p->tech );
921
922 /* Push results in a table. */
923 lua_newtable(L);
924 for (int i=0; i<array_size(o); i++) {
925 lua_pushoutfit(L,o[i]); /* value = LuaOutfit */
926 lua_rawseti(L,-2,i+1); /* store the value in the table */
927 }
928
929 array_free(o);
930 return 1;
931}
932
940static int spobL_commoditiesSold( lua_State *L )
941{
942 /* Get result and tech. */
943 Spob *p = luaL_validspob(L,1);
944
945 /* Push results in a table. */
946 lua_newtable(L);
947 for (int i=0; i<array_size(p->commodities); i++) {
948 lua_pushcommodity(L,p->commodities[i]); /* value = LuaCommodity */
949 lua_rawseti(L,-2,i+1); /* store the value in the table */
950 }
951
952 return 1;
953}
954
964static int spobL_isBlackMarket( lua_State *L )
965{
966 const Spob *p = luaL_validspob(L,1);
967 lua_pushboolean(L, spob_hasService(p, SPOB_SERVICE_BLACKMARKET));
968 return 1;
969}
970
980static int spobL_isKnown( lua_State *L )
981{
982 const Spob *s = luaL_validspob(L,1);
983 lua_pushboolean(L, spob_isKnown(s));
984 return 1;
985}
986
995static int spobL_setKnown( lua_State *L )
996{
997 Spob *p = luaL_validspob(L,1);
998 int b = lua_toboolean(L, 2);
999
1000 int changed = (b != (int)spob_isKnown(p));
1001
1002 if (b)
1003 spob_setKnown( p );
1004 else
1005 spob_rmFlag( p, SPOB_KNOWN );
1006
1007 if (changed) {
1008 ovr_refresh();
1009 /* Update outfits image array. */
1011 }
1012
1013 return 0;
1014}
1015
1024static int spobL_recordCommodityPriceAtTime( lua_State *L )
1025{
1026 const Spob *p = luaL_validspob(L,1);
1027 ntime_t t = luaL_validtime(L, 2);
1029 return 0;
1030}
1031
1041static int spobL_tags( lua_State *L )
1042{
1043 Spob *p = luaL_validspob(L,1);
1044 lua_newtable(L);
1045 for (int i=0; i<array_size(p->tags); i++) {
1046 lua_pushstring(L,p->tags[i]);
1047 lua_pushboolean(L,1);
1048 lua_rawset(L,-3);
1049 }
1050 return 1;
1051}
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
Definition array.h:158
#define array_create_size(basic_type, capacity)
Creates a new dynamic array of ‘basic_type’ with an initial capacity.
Definition array.h:102
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
Spob * land_spob
Definition land.c:83
void outfits_updateEquipmentOutfits(void)
Updates the outfitter and equipment outfit image arrays.
Header file with generic functions and naev-specifics.
#define MIN(x, y)
Definition naev.h:40
glColour * lua_pushcolour(lua_State *L, glColour colour)
Pushes a colour on the stack.
Commodity ** lua_pushcommodity(lua_State *L, Commodity *commodity)
Pushes a commodity on the stack.
LuaFaction * lua_pushfaction(lua_State *L, LuaFaction faction)
Pushes a faction on the stack.
int lua_isfaction(lua_State *L, int ind)
Checks to see if ind is a faction.
LuaFaction lua_tofaction(lua_State *L, int ind)
Gets faction at index.
const Outfit ** lua_pushoutfit(lua_State *L, const Outfit *outfit)
Pushes a outfit on the stack.
const Ship ** lua_pushship(lua_State *L, const Ship *ship)
Pushes a ship on the stack.
Definition nlua_ship.c:166
static int spobL_getLandAllow(lua_State *L)
Gets the land allow override status for a spob.
Definition nlua_spob.c:775
static int spobL_commoditiesSold(lua_State *L)
Gets the commodities sold at a spob.
Definition nlua_spob.c:940
static int spobL_gfxExterior(lua_State *L)
Gets the texture of the spob in exterior.
Definition nlua_spob.c:844
static int spobL_colour(lua_State *L)
Gets a spob's colour based on its friendliness or hostility to the player.
Definition nlua_spob.c:582
LuaSpob lua_tospob(lua_State *L, int ind)
This module allows you to handle the spobs from Lua.
Definition nlua_spob.c:149
static int spobL_landDeny(lua_State *L)
Disallows a player from landing on a spob. The override lasts until the player jumps or lands.
Definition nlua_spob.c:762
static int spobL_getLandable(lua_State *L)
Gets a spob only if it's landable.
Definition nlua_spob.c:419
static int spobL_getAll(lua_State *L)
Gets all the spobs. Lua function parameter: boolean all_spob Whether or not to get all Spob,...
Definition nlua_spob.c:430
static int spobL_radius(lua_State *L)
Gets the spob's radius.
Definition nlua_spob.c:546
static int spobL_population(lua_State *L)
Gets the spob's population.
Definition nlua_spob.c:531
static int spobL_eq(lua_State *L)
You can use the '==' operator within Lua to compare spobs with this.
Definition nlua_spob.c:473
static int spobL_outfitsSold(lua_State *L)
Gets the outfits sold at a spob.
Definition nlua_spob.c:917
static int spobL_flags(lua_State *L)
Checks for spob flags.
Definition nlua_spob.c:694
LuaSpob luaL_checkspob(lua_State *L, int ind)
Gets spob at index raising an error if isn't a spob.
Definition nlua_spob.c:160
static int spobL_colourChar(lua_State *L)
Gets a spob's colour based on its friendliness or hostility to the player.
Definition nlua_spob.c:599
static const luaL_Reg spob_methods[]
Definition nlua_spob.c:74
static int spobL_getLandDeny(lua_State *L)
Gets the land deny override status for a spob.
Definition nlua_spob.c:790
static int spobL_faction(lua_State *L)
Gets the spob's faction.
Definition nlua_spob.c:564
static int spobL_gfxSpace(lua_State *L)
Gets the texture of the spob in space.
Definition nlua_spob.c:820
static int spobL_shipsSold(lua_State *L)
Gets the ships sold at a spob.
Definition nlua_spob.c:894
static int spobL_nameRaw(lua_State *L)
Gets the spob's raw (untranslated) name.
Definition nlua_spob.c:517
static int spobL_isBlackMarket(lua_State *L)
Checks to see if a spob is a black market.
Definition nlua_spob.c:964
static int spobL_system(lua_State *L)
Gets the system corresponding to a spob. Lua function parameter: Spob p Spob to get system of....
Definition nlua_spob.c:451
static int spobL_classLong(lua_State *L)
Gets the spob's class in long human-readable format already translated.
Definition nlua_spob.c:635
static int spobL_recordCommodityPriceAtTime(lua_State *L)
Records commodity prices at a given time, adding to players stats.
Definition nlua_spob.c:1024
static int spobL_get(lua_State *L)
Gets a spob.
Definition nlua_spob.c:379
LuaSpob * lua_pushspob(lua_State *L, LuaSpob spob)
Pushes a spob on the stack.
Definition nlua_spob.c:201
static int spobL_getS(lua_State *L)
Gets a spob and its corresponding system.
Definition nlua_spob.c:403
static int spobL_canland(lua_State *L)
Gets whether or not the player can land on the spob (or bribe it).
Definition nlua_spob.c:714
static int spobL_class(lua_State *L)
Gets the spob's class.
Definition nlua_spob.c:620
static int spobL_gfxComm(lua_State *L)
Gets the texture of the spob for the communication window.
Definition nlua_spob.c:878
static int spobL_gfxExteriorPath(lua_State *L)
Gets the path of the spob in exterior.
Definition nlua_spob.c:863
static int spobL_services(lua_State *L)
Checks for spob services.
Definition nlua_spob.c:662
Spob * luaL_validspob(lua_State *L, int ind)
Gets a spob directly.
Definition nlua_spob.c:174
int nlua_loadSpob(nlua_env env)
Loads the spob library.
Definition nlua_spob.c:121
static int spobL_position(lua_State *L)
Gets the position of the spob in the system.
Definition nlua_spob.c:805
static int spobL_setKnown(lua_State *L)
Sets a spobs's known state.
Definition nlua_spob.c:995
static int spobL_tags(lua_State *L)
Gets the spob tags.
Definition nlua_spob.c:1041
static int spobL_name(lua_State *L)
Gets the spob's translated name.
Definition nlua_spob.c:498
static int spobL_isKnown(lua_State *L)
Checks to see if a spob is known by the player.
Definition nlua_spob.c:980
int lua_isspob(lua_State *L, int ind)
Checks to see if ind is a spob.
Definition nlua_spob.c:216
static int spobL_cur(lua_State *L)
Gets the current spob - MUST BE LANDED.
Definition nlua_spob.c:241
static int spobL_landAllow(lua_State *L)
Allows the player land on a spob no matter what. The override lasts until the player jumps or lands.
Definition nlua_spob.c:748
LuaSystem * lua_pushsystem(lua_State *L, LuaSystem sys)
Pushes a system on the stack.
glTexture ** lua_pushtex(lua_State *L, glTexture *texture)
Pushes a texture on the stack.
Definition nlua_tex.c:130
ntime_t luaL_validtime(lua_State *L, int ind)
Gets a time directly.
Definition nlua_time.c:115
vec2 * lua_pushvector(lua_State *L, vec2 vec)
Pushes a vector on the stack.
Definition nlua_vec2.c:145
void arrayShuffle(void **array)
Randomly sorts an array (array.h) of pointers in place with the Fisher-Yates shuffle.
Definition nmath.c:67
glTexture * gl_dupTexture(const glTexture *texture)
Duplicates a texture.
Definition opengl_tex.c:917
glTexture * gl_newImage(const char *path, const unsigned int flags)
Loads an image as a texture.
Definition opengl_tex.c:675
void spob_averageSeenPricesAtTime(const Spob *p, const ntime_t tupdate)
Adds cost of commodities on spob p to known statistics at time t.
Definition space.c:303
const glColour * spob_getColour(const Spob *p)
Gets the spob colour.
Definition space.c:1922
Spob * spob_getAll(void)
Gets an array (array.h) of all spobs.
Definition space.c:1107
Spob * spob_get(const char *spobname)
Gets a spob based on its name.
Definition space.c:1051
void space_factionChange(void)
Mark when a faction changes.
Definition space.c:1392
const char * space_getRndSpob(int landable, unsigned int services, int(*filter)(Spob *p))
Gets the name of a random spob.
Definition space.c:633
int spob_index(const Spob *p)
Gets the ID of a spob.
Definition space.c:1099
int spob_hasSystem(const Spob *spb)
Get whether or not a spob has a system (i.e. is on the map).
Definition space.c:1011
char spob_getColourChar(const Spob *p)
Gets the spob colour char.
Definition space.c:1881
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
void spob_updateLand(Spob *p)
Updates the land possibilities of a spob.
Definition space.c:1943
void spob_gfxLoad(Spob *spob)
Loads a spob's graphics (and radius).
Definition space.c:2078
Spob * spob_getIndex(int ind)
Gets spob by index.
Definition space.c:1082
const char * spob_name(const Spob *p)
Gets the translated name of a spob.
Definition space.c:1752
const char * spob_getClassName(const char *class)
Gets the long class name for a spob.
Definition space.c:215
const char * spob_getServiceName(int service)
Gets the (English) name for a service code.
Definition space.c:167
char ** space_getFactionSpob(const int *factions, int landable)
Gets the name of all the spobs that belong to factions.
Definition space.c:590
int system_index(const StarSystem *sys)
Gets the index of a star system.
Definition space.c:1000
A ship outfit, depends radically on the type.
Definition outfit.h:328
Represents a space ship.
Definition ship.h:94
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
Definition space.h:89
int can_land
Definition space.h:108
char * name
Definition space.h:91
Abstraction for rendering sprite sheets.
Definition opengl_tex.h:36
Ship ** tech_getShip(const tech_group_t *tech)
Gets all of the ships associated to a tech group.
Definition tech.c:776
Outfit ** tech_getOutfit(const tech_group_t *tech)
Gets all of the outfits associated to a tech group.
Definition tech.c:728