naev 0.12.5
nlua_ship.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"
14
15#include "nlua_ship.h"
16
17#include "array.h"
18#include "nlua_canvas.h"
19#include "nlua_faction.h"
20#include "nlua_outfit.h"
21#include "nlua_tex.h"
22#include "nluadef.h"
23#include "player.h"
24#include "slots.h"
25
26/*
27 * Prototypes.
28 */
29static const ShipOutfitSlot *ship_outfitSlotFromID( const Ship *s, int id );
30
31/* Ship metatable methods. */
32static int shipL_eq( lua_State *L );
33static int shipL_get( lua_State *L );
34static int shipL_getAll( lua_State *L );
35static int shipL_name( lua_State *L );
36static int shipL_nameRaw( lua_State *L );
37static int shipL_baseType( lua_State *L );
38static int shipL_inherits( lua_State *L );
39static int shipL_class( lua_State *L );
40static int shipL_classDisplay( lua_State *L );
41static int shipL_faction( lua_State *L );
42static int shipL_fabricator( lua_State *L );
43static int shipL_crew( lua_State *L );
44static int shipL_mass( lua_State *L );
45static int shipL_armour( lua_State *L );
46static int shipL_cargo( lua_State *L );
47static int shipL_fuelConsumption( lua_State *L );
48static int shipL_license( lua_State *L );
49static int shipL_points( lua_State *L );
50static int shipL_slots( lua_State *L );
51static int shipL_getSlots( lua_State *L );
52static int shipL_fitsSlot( lua_State *L );
53static int shipL_CPU( lua_State *L );
54static int shipL_gfxPath( lua_State *L );
55static int shipL_gfxComm( lua_State *L );
56static int shipL_gfxStore( lua_State *L );
57static int shipL_gfx( lua_State *L );
58static int shipL_dims( lua_State *L );
59static int shipL_screenSize( lua_State *L );
60static int shipL_price( lua_State *L );
61static int shipL_time_mod( lua_State *L );
62static int shipL_getSize( lua_State *L );
63static int shipL_description( lua_State *L );
64static int shipL_getShipStat( lua_State *L );
65static int shipL_getShipStatDesc( lua_State *L );
66static int shipL_known( lua_State *L );
67static int shipL_tags( lua_State *L );
68static int shipL_render( lua_State *L );
69
70static const luaL_Reg shipL_methods[] = {
71 { "__tostring", shipL_name },
72 { "__eq", shipL_eq },
73 { "get", shipL_get },
74 { "getAll", shipL_getAll },
75 { "name", shipL_name },
76 { "nameRaw", shipL_nameRaw },
77 { "baseType", shipL_baseType },
78 { "inherits", shipL_inherits },
79 { "class", shipL_class },
80 { "classDisplay", shipL_classDisplay },
81 { "faction", shipL_faction },
82 { "fabricator", shipL_fabricator },
83 { "crew", shipL_crew },
84 { "mass", shipL_mass },
85 { "armour", shipL_armour },
86 { "cargo", shipL_cargo },
87 { "fuelConsumption", shipL_fuelConsumption },
88 { "license", shipL_license },
89 { "points", shipL_points },
90 { "slots", shipL_slots },
91 { "getSlots", shipL_getSlots },
92 { "fitsSlot", shipL_fitsSlot },
93 { "cpu", shipL_CPU },
94 { "price", shipL_price },
95 { "time_mod", shipL_time_mod },
96 { "size", shipL_getSize },
97 { "gfxPath", shipL_gfxPath },
98 { "gfxComm", shipL_gfxComm },
99 { "gfxStore", shipL_gfxStore },
100 { "gfx", shipL_gfx },
101 { "dims", shipL_dims },
102 { "screenSize", shipL_screenSize },
103 { "description", shipL_description },
104 { "shipstat", shipL_getShipStat },
105 { "shipstatDesc", shipL_getShipStatDesc },
106 { "known", shipL_known },
107 { "tags", shipL_tags },
108 { "render", shipL_render },
109 { 0, 0 } };
110
117int nlua_loadShip( nlua_env env )
118{
119 nlua_register( env, SHIP_METATABLE, shipL_methods, 1 );
120 return 0;
121}
122
143const Ship *lua_toship( lua_State *L, int ind )
144{
145 return *( (Ship **)lua_touserdata( L, ind ) );
146}
147
154const Ship *luaL_checkship( lua_State *L, int ind )
155{
156 if ( lua_isship( L, ind ) )
157 return lua_toship( L, ind );
158 luaL_typerror( L, ind, SHIP_METATABLE );
159 return NULL;
160}
161
168const Ship *luaL_validship( lua_State *L, int ind )
169{
170 const Ship *s;
171
172 if ( lua_isship( L, ind ) )
173 s = luaL_checkship( L, ind );
174 else if ( lua_isstring( L, ind ) )
175 s = ship_get( lua_tostring( L, ind ) );
176 else {
177 luaL_typerror( L, ind, SHIP_METATABLE );
178 return NULL;
179 }
180
181 if ( s == NULL )
182 NLUA_ERROR( L, _( "Ship is invalid." ) );
183
184 return s;
185}
186
193const Ship **lua_pushship( lua_State *L, const Ship *ship )
194{
195 const Ship **p;
196 p = (const Ship **)lua_newuserdata( L, sizeof( Ship *) );
197 *p = ship;
198 luaL_getmetatable( L, SHIP_METATABLE );
199 lua_setmetatable( L, -2 );
200 return p;
201}
202
209int lua_isship( lua_State *L, int ind )
210{
211 int ret;
212
213 if ( lua_getmetatable( L, ind ) == 0 )
214 return 0;
215 lua_getfield( L, LUA_REGISTRYINDEX, SHIP_METATABLE );
216
217 ret = 0;
218 if ( lua_rawequal( L, -1, -2 ) ) /* does it have the correct mt? */
219 ret = 1;
220
221 lua_pop( L, 2 ); /* remove both metatables */
222 return ret;
223}
224
235static int shipL_eq( lua_State *L )
236{
237 const Ship *a, *b;
238 a = luaL_checkship( L, 1 );
239 b = luaL_checkship( L, 2 );
240 if ( a == b )
241 lua_pushboolean( L, 1 );
242 else
243 lua_pushboolean( L, 0 );
244 return 1;
245}
246
256static int shipL_get( lua_State *L )
257{
258 const Ship *ship = luaL_validship( L, 1 );
259 lua_pushship( L, ship );
260 return 1;
261}
262
269static int shipL_getAll( lua_State *L )
270{
271 const Ship *ships = ship_getAll();
272 lua_newtable( L ); /* t */
273 for ( int i = 0; i < array_size( ships ); i++ ) {
274 lua_pushship( L, &ships[i] );
275 lua_rawseti( L, -2, i + 1 );
276 }
277 return 1;
278}
279
293static int shipL_name( lua_State *L )
294{
295 const Ship *s = luaL_validship( L, 1 );
296 lua_pushstring( L, _( s->name ) );
297 return 1;
298}
299
313static int shipL_nameRaw( lua_State *L )
314{
315 const Ship *s = luaL_validship( L, 1 );
316 lua_pushstring( L, s->name );
317 return 1;
318}
319
332static int shipL_baseType( lua_State *L )
333{
334 const Ship *s = luaL_validship( L, 1 );
335 lua_pushstring( L, s->base_type );
336 return 1;
337}
338
347static int shipL_inherits( lua_State *L )
348{
349 const Ship *s = luaL_validship( L, 1 );
350 if ( s->inherits == NULL )
351 return 0;
352 lua_pushship( L, ship_get( s->inherits ) );
353 return 1;
354}
355
365static int shipL_class( lua_State *L )
366{
367 const Ship *s = luaL_validship( L, 1 );
368 lua_pushstring( L, ship_class( s ) );
369 return 1;
370}
371
382static int shipL_classDisplay( lua_State *L )
383{
384 const Ship *s = luaL_validship( L, 1 );
385 lua_pushstring( L, ship_classDisplay( s ) );
386 return 1;
387}
388
398static int shipL_faction( lua_State *L )
399{
400 const Ship *s = luaL_validship( L, 1 );
401 if ( faction_isFaction( s->faction ) ) {
402 lua_pushfaction( L, s->faction );
403 return 1;
404 }
405 return 0;
406}
407
415static int shipL_fabricator( lua_State *L )
416{
417 const Ship *s = luaL_validship( L, 1 );
418 lua_pushstring( L, s->fabricator );
419 return 1;
420}
421
429static int shipL_crew( lua_State *L )
430{
431 const Ship *s = luaL_validship( L, 1 );
432 lua_pushinteger( L, s->crew );
433 return 1;
434}
435
443static int shipL_mass( lua_State *L )
444{
445 const Ship *s = luaL_validship( L, 1 );
446 lua_pushnumber( L, s->mass );
447 return 1;
448}
449
457static int shipL_armour( lua_State *L )
458{
459 const Ship *s = luaL_validship( L, 1 );
460 lua_pushnumber( L, s->armour );
461 return 1;
462}
463
471static int shipL_cargo( lua_State *L )
472{
473 const Ship *s = luaL_validship( L, 1 );
474 lua_pushnumber( L, s->cap_cargo );
475 return 1;
476}
477
485static int shipL_fuelConsumption( lua_State *L )
486{
487 const Ship *s = luaL_validship( L, 1 );
488 lua_pushnumber( L, s->fuel_consumption );
489 return 1;
490}
491
501static int shipL_license( lua_State *L )
502{
503 const Ship *s = luaL_validship( L, 1 );
504 if ( s->license == NULL )
505 return 0;
506 lua_pushstring( L, s->license );
507 return 1;
508}
509
520static int shipL_points( lua_State *L )
521{
522 const Ship *s = luaL_validship( L, 1 );
523 lua_pushinteger( L, s->points );
524 return 1;
525}
526
538static int shipL_slots( lua_State *L )
539{
540 const Ship *s = luaL_validship( L, 1 );
541 /* Push slot numbers. */
542 lua_pushnumber( L, array_size( s->outfit_weapon ) );
543 lua_pushnumber( L, array_size( s->outfit_utility ) );
544 lua_pushnumber( L, array_size( s->outfit_structure ) );
545 return 3;
546}
547
563static int shipL_getSlots( lua_State *L )
564{
565 int k;
566 const Ship *s = luaL_validship( L, 1 );
567 int ignore_locked = lua_toboolean( L, 2 );
568 const ShipOutfitSlot *outfit_arrays[] = {
570
571 lua_newtable( L );
572 k = 1;
573 for ( int i = 0; i < 3; i++ ) {
574 for ( int j = 0; j < array_size( outfit_arrays[i] ); j++ ) {
575 const OutfitSlot *slot = &outfit_arrays[i][j].slot;
576 const ShipOutfitSlot *sslot = &outfit_arrays[i][j];
577
578 /* Skip locked if necessary. */
579 if ( ignore_locked && sslot->locked )
580 continue;
581
582 /* make the slot table and put it in */
583 lua_newtable( L );
584
585 /* Index can be used as an ID (at least for now...) */
586#if 0
587 lua_pushstring(L, "id" ); /* key */
588 lua_pushinteger(L, k); /* value */
589 lua_rawset(L, -3); /* table[key] = value*/
590#endif
591
592 lua_pushstring( L, "type" ); /* key */
593 lua_pushstring( L, slotName( slot->type ) ); /* value */
594 lua_rawset( L, -3 ); /* table[key] = value*/
595
596 lua_pushstring( L, "size" ); /* key */
597 lua_pushstring( L, slotSize( slot->size ) );
598 lua_rawset( L, -3 ); /* table[key] = value */
599
600 lua_pushstring( L, "property" ); /* key */
601 lua_pushstring( L, sp_display( slot->spid ) ); /* value */
602 lua_rawset( L, -3 ); /* table[key] = value */
603
604 lua_pushstring( L, "required" ); /* key */
605 lua_pushboolean( L, sslot->required ); /* value */
606 lua_rawset( L, -3 ); /* table[key] = value */
607
608 lua_pushstring( L, "exclusive" ); /* key */
609 lua_pushboolean( L, sslot->exclusive ); /* value */
610 lua_rawset( L, -3 ); /* table[key] = value */
611
612 lua_pushstring( L, "locked" ); /* key */
613 lua_pushboolean( L, sslot->locked ); /* value */
614 lua_rawset( L, -3 ); /* table[key] = value */
615
616 lua_pushstring( L, "visible" ); /* key */
617 lua_pushboolean( L, sslot->visible ); /* value */
618 lua_rawset( L, -3 ); /* table[key] = value */
619
620 if ( sslot->data != NULL ) {
621 lua_pushstring( L, "outfit" ); /* key */
622 lua_pushoutfit( L, sslot->data ); /* value*/
623 lua_rawset( L, -3 ); /* table[key] = value */
624 }
625
626 lua_rawseti( L, -2, k++ ); /* put the slot table in */
627 }
628 }
629
630 return 1;
631}
632
639static const ShipOutfitSlot *ship_outfitSlotFromID( const Ship *s, int id )
640{
641 const ShipOutfitSlot *outfit_arrays[] = {
643
644 for ( int i = 0; i < 3; i++ ) {
645 int n = array_size( outfit_arrays[i] );
646 if ( id <= n )
647 return &outfit_arrays[i][id - 1];
648 id -= n;
649 }
650 return NULL;
651}
652
662static int shipL_fitsSlot( lua_State *L )
663{
664 const Ship *s = luaL_validship( L, 1 );
665 int id = luaL_checkinteger( L, 2 );
666 const Outfit *o = luaL_validoutfit( L, 3 );
667 const ShipOutfitSlot *ss = ship_outfitSlotFromID( s, id );
668 if ( ss->locked ) {
669 lua_pushboolean( L, 0 );
670 return 1;
671 }
672 lua_pushboolean( L, outfit_fitsSlot( o, &ss->slot ) );
673 return 1;
674}
675
685static int shipL_CPU( lua_State *L )
686{
687 const Ship *s = luaL_validship( L, 1 );
688 lua_pushnumber( L, s->cpu );
689 return 1;
690}
691
702static int shipL_price( lua_State *L )
703{
704 const Ship *s = luaL_validship( L, 1 );
705 lua_pushnumber( L, ship_buyPrice( s ) );
706 lua_pushnumber( L, ship_basePrice( s ) );
707 return 2;
708}
709
717static int shipL_time_mod( lua_State *L )
718{
719 const Ship *s = luaL_validship( L, 1 );
720 lua_pushnumber( L, s->dt_default );
721 return 1;
722}
723
732static int shipL_getSize( lua_State *L )
733{
734 const Ship *s = luaL_validship( L, 1 );
735 lua_pushinteger( L, ship_size( s ) );
736 return 1;
737}
738
747static int shipL_gfxPath( lua_State *L )
748{
749 const Ship *s = luaL_validship( L, 1 );
750 lua_pushstring( L, s->gfx_path );
751 return 1;
752}
753
766static int shipL_gfxComm( lua_State *L )
767{
768 const Ship *s = luaL_validship( L, 1 );
769 int size = luaL_optinteger( L, 2, 512 );
770 glTexture *tex = ship_gfxComm( s, size, 0., 0., &L_store_const );
771 if ( tex == NULL ) {
772 NLUA_WARN( L, _( "Unable to get ship comm graphic for '%s'." ), s->name );
773 return 0;
774 }
775 lua_pushtex( L, tex );
776 return 1;
777}
778
790static int shipL_gfxStore( lua_State *L )
791{
792 const Ship *s = luaL_validship( L, 1 );
793 glTexture *tex = ship_gfxStore( s, 256, 0., 0., 0. );
794 if ( tex == NULL ) {
795 NLUA_WARN( L, _( "Unable to get ship store graphic for '%s'." ),
796 s->name );
797 return 0;
798 }
799 lua_pushtex( L, tex );
800 return 1;
801}
802
815static int shipL_gfx( lua_State *L )
816{
817 const Ship *s = luaL_validship( L, 1 );
818 ship_gfxLoad( (Ship *)s );
819 glTexture *tex = gl_dupTexture( s->gfx_space );
820 if ( tex == NULL ) {
821 NLUA_WARN( L, _( "Unable to get ship graphic for '%s'." ), s->name );
822 return 0;
823 }
824 lua_pushtex( L, tex );
825 return 1;
826}
827
835static int shipL_dims( lua_State *L )
836{
837 const Ship *s = luaL_validship( L, 1 );
838 lua_pushnumber( L, s->size );
839 lua_pushnumber( L, s->size );
840 return 2;
841}
842
849static int shipL_screenSize( lua_State *L )
850{
851 const Ship *s = luaL_validship( L, 1 );
852 lua_pushnumber( L, s->size );
853 return 1;
854}
855
865static int shipL_description( lua_State *L )
866{
867 const Ship *s = luaL_validship( L, 1 );
868 lua_pushstring( L, _( s->description ) );
869 return 1;
870}
871
884static int shipL_getShipStat( lua_State *L )
885{
886 const Ship *s = luaL_validship( L, 1 );
887 const char *str = luaL_optstring( L, 2, NULL );
888 int internal = lua_toboolean( L, 3 );
889 ss_statsGetLua( L, &s->stats_array, str, internal );
890 return 1;
891}
892
900static int shipL_getShipStatDesc( lua_State *L )
901{
902 char buf[STRMAX];
903 const Ship *s = luaL_validship( L, 1 );
904 ss_statsDesc( &s->stats_array, buf, sizeof( buf ), 0 );
905 lua_pushstring( L, buf );
906 return 1;
907}
908
913static int shipL_known( lua_State *L )
914{
915 /* TODO cache this and mark as dirty instead of recomputing for each outfit.
916 */
917 const Ship *s = luaL_validship( L, 1 );
918 const PlayerShip_t *ps = player_getShipStack();
919 for ( int i = 0; i < array_size( ps ); i++ ) {
920 if ( ps[i].p->ship == s ) {
921 lua_pushboolean( L, 1 );
922 return 1;
923 }
924 }
925 const Spob *ss = spob_getAll();
926 for ( int i = 0; i < array_size( ss ); i++ ) {
927 const Spob *spb = &ss[i];
928 if ( !spob_hasService( spb, SPOB_SERVICE_SHIPYARD ) )
929 continue;
930 if ( !spob_isKnown( spb ) )
931 continue;
932 if ( tech_hasShip( spb->tech, s ) ) {
933 lua_pushboolean( L, 1 );
934 return 1;
935 }
936 }
937 lua_pushboolean( L, 0 );
938 return 1;
939}
940
954static int shipL_tags( lua_State *L )
955{
956 const Ship *s = luaL_validship( L, 1 );
957 return nlua_helperTags( L, 2, s->tags );
958}
959
970static int shipL_render( lua_State *L )
971{
972 LuaCanvas_t lc;
973 int w, h, sx, sy;
974 const Ship *s = luaL_validship( L, 1 );
975 double dir = luaL_checknumber( L, 2 );
976 double eg = luaL_optnumber( L, 3, 0. );
977 double tilt = luaL_optnumber( L, 4, 0. );
978
979 ship_gfxLoad( (Ship *)s );
980
981 gl_getSpriteFromDir( &sx, &sy, s->sx, s->sy, dir );
982
983 w = s->size;
984 h = s->size;
985 if ( canvas_new( &lc, w, h ) )
986 return NLUA_ERROR( L, _( "Error setting up framebuffer!" ) );
987
988 /* The code path below is really buggy.
989 * 1. engine_glow seems to scale 3D models improperly when interpolating, so
990 * it's disabled.
991 * 2. for some reason, have to pass real dimensions and not fbo dimensions.
992 * TODO fix this shit. */
993 ship_renderFramebuffer( s, lc.fbo, gl_screen.rw, gl_screen.rh, dir, eg, tilt,
994 0., sx, sy, NULL, NULL );
995
996 lua_pushcanvas( L, lc );
997 return 1;
998}
Provides macros to work with dynamic arrays.
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
Definition array.h:179
int faction_isFaction(int f)
Checks whether or not a faction is valid.
Definition faction.c:1539
Header file with generic functions and naev-specifics.
int nlua_helperTags(lua_State *L, int idx, char *const *tags)
Helper function to deal with tags.
Definition nlua.c:1118
LuaFaction * lua_pushfaction(lua_State *L, LuaFaction faction)
Pushes a faction on the stack.
const Outfit * luaL_validoutfit(lua_State *L, int ind)
Makes sure the outfit is valid or raises a Lua error.
const Outfit ** lua_pushoutfit(lua_State *L, const Outfit *outfit)
Pushes a outfit on the stack.
static int shipL_tags(lua_State *L)
Gets the ship tags.
Definition nlua_ship.c:954
static int shipL_getSize(lua_State *L)
Gets the ship's size. Ultra-light is 1, light is 2, medium is 3, heavy-medium is 4,...
Definition nlua_ship.c:732
static int shipL_getShipStatDesc(lua_State *L)
Gets the ship stats description for a ship.
Definition nlua_ship.c:900
static int shipL_cargo(lua_State *L)
Gets the number of cargo of the ship.
Definition nlua_ship.c:471
static int shipL_mass(lua_State *L)
Gets the number of mass of the ship.
Definition nlua_ship.c:443
static int shipL_fuelConsumption(lua_State *L)
Gets the number of fuel consumption of the ship.
Definition nlua_ship.c:485
static int shipL_getShipStat(lua_State *L)
Gets a shipstat from an Ship by name, or a table containing all the ship stats if not specified.
Definition nlua_ship.c:884
static int shipL_fabricator(lua_State *L)
Gets the raw (untranslated) fabricator of the ship.
Definition nlua_ship.c:415
static int shipL_price(lua_State *L)
Gets the ship's price, with and without default outfits.
Definition nlua_ship.c:702
static int shipL_gfxStore(lua_State *L)
Gets the ship's store graphics.
Definition nlua_ship.c:790
static int shipL_license(lua_State *L)
Gets license required for the ship.
Definition nlua_ship.c:501
static int shipL_screenSize(lua_State *L)
Gets the onscreen size of the ship.
Definition nlua_ship.c:849
static int shipL_render(lua_State *L)
Renders the pilot to a canvas.
Definition nlua_ship.c:970
const Ship ** lua_pushship(lua_State *L, const Ship *ship)
Pushes a ship on the stack.
Definition nlua_ship.c:193
int nlua_loadShip(nlua_env env)
Loads the ship library.
Definition nlua_ship.c:117
static int shipL_crew(lua_State *L)
Gets the number of crew of the ship.
Definition nlua_ship.c:429
static int shipL_class(lua_State *L)
Gets the raw (untranslated) name of the ship's class.
Definition nlua_ship.c:365
int lua_isship(lua_State *L, int ind)
Checks to see if ind is a ship.
Definition nlua_ship.c:209
static int shipL_known(lua_State *L)
Gets whether or not the ship is known to the player, as in they know a spob that sells it or own it.
Definition nlua_ship.c:913
static int shipL_dims(lua_State *L)
Gets the onscreen dimensions of the ship.
Definition nlua_ship.c:835
static int shipL_time_mod(lua_State *L)
Gets the ship's time_mod.
Definition nlua_ship.c:717
static int shipL_armour(lua_State *L)
Gets the number of armour of the ship.
Definition nlua_ship.c:457
const Ship * luaL_validship(lua_State *L, int ind)
Makes sure the ship is valid or raises a Lua error.
Definition nlua_ship.c:168
const Ship * luaL_checkship(lua_State *L, int ind)
Gets ship at index or raises error if there is no ship at index.
Definition nlua_ship.c:154
static int shipL_eq(lua_State *L)
Checks to see if two ships are the same.
Definition nlua_ship.c:235
static int shipL_getSlots(lua_State *L)
Get a table of slots of a ship, where a slot is a table with a string size, type, and property.
Definition nlua_ship.c:563
static int shipL_CPU(lua_State *L)
Gets the ship available CPU.
Definition nlua_ship.c:685
static int shipL_gfxComm(lua_State *L)
Gets the ship's comm graphics.
Definition nlua_ship.c:766
const Ship * lua_toship(lua_State *L, int ind)
Lua bindings to interact with ships.
Definition nlua_ship.c:143
static int shipL_baseType(lua_State *L)
Gets the raw (untranslated) name of the ship's base type.
Definition nlua_ship.c:332
static int shipL_inherits(lua_State *L)
Gets the ship it inherits stats from if applicable.
Definition nlua_ship.c:347
static int shipL_nameRaw(lua_State *L)
Gets the raw (untranslated) name of the ship.
Definition nlua_ship.c:313
static int shipL_points(lua_State *L)
Gets the point value of a ship. Used for comparing relative ship strengths (minus outfits).
Definition nlua_ship.c:520
static int shipL_gfxPath(lua_State *L)
Gets the path where the ship's graphics are located. Useful for seeing if two ships share the same gr...
Definition nlua_ship.c:747
static const luaL_Reg shipL_methods[]
Definition nlua_ship.c:70
static int shipL_slots(lua_State *L)
Gets the amount of the ship's slots.
Definition nlua_ship.c:538
static int shipL_description(lua_State *L)
Gets the description of the ship (translated).
Definition nlua_ship.c:865
static int shipL_classDisplay(lua_State *L)
Gets the raw (untranslated) display name of the ship's class (not ship's base class).
Definition nlua_ship.c:382
static const ShipOutfitSlot * ship_outfitSlotFromID(const Ship *s, int id)
Gets an outfit slot from ID.
Definition nlua_ship.c:639
static int shipL_getAll(lua_State *L)
Gets a table containing all the ships.
Definition nlua_ship.c:269
static int shipL_faction(lua_State *L)
Gets the faction of a ship.
Definition nlua_ship.c:398
static int shipL_name(lua_State *L)
Gets the translated name of the ship.
Definition nlua_ship.c:293
static int shipL_get(lua_State *L)
Gets a ship.
Definition nlua_ship.c:256
static int shipL_gfx(lua_State *L)
Gets the ship's graphics.
Definition nlua_ship.c:815
static int shipL_fitsSlot(lua_State *L)
Checks to see if an outfit fits a ship slot.
Definition nlua_ship.c:662
glTexture ** lua_pushtex(lua_State *L, glTexture *texture)
Pushes a texture on the stack.
Definition nlua_tex.c:129
glInfo gl_screen
Definition opengl.c:47
glTexture * gl_dupTexture(const glTexture *texture)
Duplicates a texture.
Definition opengl_tex.c:891
void gl_getSpriteFromDir(int *x, int *y, int sx, int sy, double dir)
Sets x and y to be the appropriate sprite for glTexture using dir.
Definition opengl_tex.c:977
int outfit_fitsSlot(const Outfit *o, const OutfitSlot *s)
Checks to see if an outfit fits a slot.
Definition outfit.c:1180
const char * slotName(const OutfitSlotType type)
Definition outfit.c:413
const char * slotSize(const OutfitSlotSize o)
Gets the slot size as a string.
Definition outfit.c:436
const PlayerShip_t * player_getShipStack(void)
Gets the array (array.h) of the player's ships.
Definition player.c:2804
int ship_size(const Ship *s)
Gets the size of the ship.
Definition ship.c:526
const char * ship_class(const Ship *s)
Gets the ship's class name in human readable form.
Definition ship.c:192
const char * ship_classDisplay(const Ship *s)
Gets the ship's display class in human readable form.
Definition ship.c:203
credits_t ship_basePrice(const Ship *s)
Gets the ship's base price (no outfits).
Definition ship.c:295
credits_t ship_buyPrice(const Ship *s)
The ship buy price, includes default outfits.
Definition ship.c:303
const Ship * ship_getAll(void)
Gets the array (array.h) of all ships.
Definition ship.c:134
glTexture * ship_gfxComm(const Ship *s, int size, double tilt, double dir, const Lighting *Lscene)
Loads the ship's comm graphic.
Definition ship.c:418
void ship_renderFramebuffer(const Ship *s, GLuint fbo, double fw, double fh, double dir, double engine_glow, double tilt, double r, int sx, int sy, const glColour *c, const Lighting *L)
Renders a ship to a framebuffer.
Definition ship.c:1489
glTexture * ship_gfxStore(const Ship *s, int size, double dir, double updown, double glow)
Get the store gfx.
Definition ship.c:383
const Ship * ship_get(const char *name)
Gets a ship based on its name.
Definition ship.c:99
int ship_gfxLoad(Ship *s)
Loads the graphics for a ship if necessary.
Definition ship.c:628
int ss_statsGetLua(lua_State *L, const ShipStats *s, const char *name, int internal)
Gets a ship stat value by name and pushes it to Lua.
Definition shipstats.c:1116
int ss_statsDesc(const ShipStats *s, char *buf, int len, int newline)
Writes the ship statistics description.
Definition shipstats.c:864
const char * sp_display(unsigned int spid)
Gets the display name of a slot property (in English).
Definition slots.c:165
Spob * spob_getAll(void)
Gets an array (array.h) of all spobs.
Definition space.c:1166
Wrapper to canvass.
Definition nlua_canvas.h:15
Pilot slot that can contain outfits.
Definition outfit.h:139
OutfitSlotSize size
Definition outfit.h:143
unsigned int spid
Definition outfit.h:140
OutfitSlotType type
Definition outfit.h:142
A ship outfit, depends radically on the type.
Definition outfit.h:372
Player ship.
Definition player.h:72
Ship outfit slot.
Definition ship.h:71
int exclusive
Definition ship.h:74
int required
Definition ship.h:75
const Outfit * data
Definition ship.h:78
int visible
Definition ship.h:77
OutfitSlot slot
Definition ship.h:72
int locked
Definition ship.h:76
Represents a space ship.
Definition ship.h:97
double dt_default
Definition ship.h:136
double cap_cargo
Definition ship.h:135
glTexture * gfx_space
Definition ship.h:154
ShipStats stats_array
Definition ship.h:182
char * license
Definition ship.h:116
char * name
Definition ship.h:100
char * fabricator
Definition ship.h:120
char * description
Definition ship.h:121
int faction
Definition ship.h:108
char * base_type
Definition ship.h:101
double armour
Definition ship.h:139
int fuel_consumption
Definition ship.h:134
int crew
Definition ship.h:130
int points
Definition ship.h:110
double cpu
Definition ship.h:132
ShipOutfitSlot * outfit_utility
Definition ship.h:174
char ** tags
Definition ship.h:185
char * inherits
Definition ship.h:99
ShipOutfitSlot * outfit_weapon
Definition ship.h:175
double size
Definition ship.h:149
char * gfx_path
Definition ship.h:150
double mass
Definition ship.h:131
ShipOutfitSlot * outfit_structure
Definition ship.h:172
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
Definition space.h:102
tech_group_t * tech
Definition space.h:137
Abstraction for rendering sprite sheets.
Definition opengl_tex.h:43
int tech_hasShip(const tech_group_t *tech, const Ship *ship)
Checks to see whether a tech group contains a ship.
Definition tech.c:739