naev 0.11.5
nlua_naev.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_naev.h"
16
17#include "array.h"
18#include "console.h"
19#include "hook.h"
20#include "input.h"
21#include "land.h"
22#include "log.h"
23#include "info.h"
24#include "menu.h"
25#include "nlua_evt.h"
26#include "nlua_misn.h"
27#include "nlua_system.h"
28#include "nluadef.h"
29#include "nstring.h"
30#include "pause.h"
31#include "player.h"
32#include "plugin.h"
33#include "semver.h"
34
35static int cache_table = LUA_NOREF; /* No reference. */
36
37/* Naev methods. */
38static int naevL_version( lua_State *L );
39static int naevL_versionTest( lua_State *L );
40static int naevL_language( lua_State *L );
41static int naevL_lastplayed( lua_State *L );
42static int naevL_ticks( lua_State *L );
43static int naevL_ticksGame( lua_State *L );
44static int naevL_clock( lua_State *L );
45static int naevL_fps( lua_State *L );
46static int naevL_keyGet( lua_State *L );
47static int naevL_keyEnable( lua_State *L );
48static int naevL_keyEnableAll( lua_State *L );
49static int naevL_keyDisableAll( lua_State *L );
50static int naevL_eventStart( lua_State *L );
51static int naevL_eventReload( lua_State *L );
52static int naevL_missionList( lua_State *L );
53static int naevL_missionStart( lua_State *L );
54static int naevL_missionTest( lua_State *L );
55static int naevL_missionReload( lua_State *L );
56static int naevL_shadersReload( lua_State *L );
57static int naevL_isSimulation( lua_State *L );
58static int naevL_conf( lua_State *L );
59static int naevL_confSet( lua_State *L );
60static int naevL_cache( lua_State *L );
61static int naevL_trigger( lua_State *L );
62static int naevL_claimTest( lua_State *L );
63static int naevL_plugins( lua_State *L );
64static int naevL_menuInfo( lua_State *L );
65static int naevL_menuSmall( lua_State *L );
66static int naevL_isPaused( lua_State *L );
67static int naevL_pause( lua_State *L );
68static int naevL_unpause( lua_State *L );
69static int naevL_hasTextInput( lua_State *L );
70static int naevL_setTextInput( lua_State *L );
71static int naevL_unit( lua_State *L );
72static int naevL_quadtreeParams( lua_State *L );
73#if DEBUGGING
74static int naevL_envs( lua_State *L );
75#endif /* DEBUGGING */
76static const luaL_Reg naev_methods[] = {
77 { "version", naevL_version },
78 { "versionTest", naevL_versionTest },
79 { "language", naevL_language },
80 { "lastplayed", naevL_lastplayed },
81 { "ticks", naevL_ticks },
82 { "ticksGame", naevL_ticksGame },
83 { "clock", naevL_clock },
84 { "fps", naevL_fps },
85 { "keyGet", naevL_keyGet },
86 { "keyEnable", naevL_keyEnable },
87 { "keyEnableAll", naevL_keyEnableAll },
88 { "keyDisableAll", naevL_keyDisableAll },
89 { "eventStart", naevL_eventStart },
90 { "eventReload", naevL_eventReload },
91 { "missionList", naevL_missionList },
92 { "missionStart", naevL_missionStart },
93 { "missionTest", naevL_missionTest },
94 { "missionReload", naevL_missionReload },
95 { "shadersReload", naevL_shadersReload },
96 { "isSimulation", naevL_isSimulation },
97 { "conf", naevL_conf },
98 { "confSet", naevL_confSet },
99 { "cache", naevL_cache },
100 { "trigger", naevL_trigger },
101 { "claimTest", naevL_claimTest },
102 { "plugins", naevL_plugins },
103 { "menuInfo", naevL_menuInfo },
104 { "menuSmall", naevL_menuSmall },
105 { "isPaused", naevL_isPaused },
106 { "pause", naevL_pause },
107 { "unpause", naevL_unpause },
108 { "hasTextInput", naevL_hasTextInput },
109 { "setTextInput", naevL_setTextInput },
110 { "unit", naevL_unit },
111 { "quadtreeParams", naevL_quadtreeParams },
112#if DEBUGGING
113 { "envs", naevL_envs },
114#endif /* DEBUGGING */
115 {0,0}
116};
124int nlua_loadNaev( nlua_env env )
125{
126 nlua_register(env, "naev", naev_methods, 0);
127
128 /* Create cache. */
129 if (cache_table == LUA_NOREF) {
130 lua_newtable( naevL );
131 cache_table = luaL_ref(naevL, LUA_REGISTRYINDEX);
132 }
133
134 return 0;
135}
136
152static int naevL_version( lua_State *L )
153{
154 lua_pushstring( L, naev_version(0) );
155 if (player.loaded_version==NULL)
156 lua_pushnil( L );
157 else
158 lua_pushstring( L, player.loaded_version );
159 return 2;
160}
161
170static int naevL_versionTest( lua_State *L )
171{
172 const char *s1, *s2;
173 semver_t sv1, sv2;
174 int res;
175 /* Parse inputs. */
176 s1 = luaL_checkstring(L,1);
177 s2 = luaL_checkstring(L,2);
178 if (semver_parse( s1, &sv1 ))
179 WARN( _("Failed to parse version string '%s'!"), s1 );
180 if (semver_parse( s2, &sv2 ))
181 WARN( _("Failed to parse version string '%s'!"), s2 );
182
183 /* Check version. */
184 res = semver_compare( sv1, sv2 );
185
186 /* Cleanup. */
187 semver_free( &sv1 );
188 semver_free( &sv2 );
189
190 lua_pushinteger(L,res);
191 return 1;
192}
193
200static int naevL_language( lua_State *L )
201{
202 lua_pushstring( L, gettext_getLanguage() );
203 return 1;
204}
205
213static int naevL_lastplayed( lua_State *L )
214{
215 double d = difftime( time(NULL), player.last_played );
216 double g = difftime( time(NULL), conf.last_played );
217 lua_pushnumber(L, d/(3600.*24.)); /*< convert to days */
218 lua_pushnumber(L, g/(3600.*24.)); /*< convert to days */
219 return 2;
220}
221
230static int naevL_ticksGame( lua_State *L )
231{
232 lua_pushnumber(L, elapsed_time_mod );
233 return 1;
234}
235
244static int naevL_ticks( lua_State *L )
245{
246 lua_pushnumber(L, (double)SDL_GetTicks64() / 1000.);
247 return 1;
248}
249
256static int naevL_clock( lua_State *L )
257{
258 lua_pushnumber(L, (double)clock() / (double)CLOCKS_PER_SEC );
259 return 1;
260}
261
268static int naevL_fps( lua_State *L )
269{
270 lua_pushnumber(L, fps_current());
271 return 1;
272}
273
282static int naevL_keyGet( lua_State *L )
283{
284 char buf[128];
285 const char *keyname = luaL_checkstring( L, 1 );
286
287 input_getKeybindDisplay( keyname, buf, sizeof(buf) );
288 lua_pushstring( L, buf );
289
290 return 1;
291}
292
303static int naevL_keyEnable( lua_State *L )
304{
305 const char *key = luaL_checkstring(L,1);
306 int enable = lua_toboolean(L,2);
307
308 input_toggleEnable( key, enable );
309 return 0;
310}
311
318static int naevL_keyEnableAll( lua_State *L )
319{
320 (void) L;
322 return 0;
323}
324
331static int naevL_keyDisableAll( lua_State *L )
332{
333 (void) L;
335 return 0;
336}
337
346static int naevL_eventStart( lua_State *L )
347{
348 const char *str = luaL_checkstring(L, 1);
349 int ret = event_start( str, NULL );
350
351 if (cli_isOpen() && landed)
352 bar_regen();
353
354 lua_pushboolean( L, !ret );
355 return 1;
356}
357
364static int naevL_missionList( lua_State *L )
365{
366 const MissionData *misns = mission_list();
367 lua_newtable(L);
368 for (int i=0; i<array_size(misns); i++) {
369 misn_pushMissionData( L, &misns[i] );
370 lua_rawseti(L,-2,i+1);
371 }
372 return 1;
373}
374
384static int naevL_missionStart( lua_State *L )
385{
386 const char *str = luaL_checkstring(L, 1);
387 int ret = mission_start( str, NULL );
388
389 if (cli_isOpen() && landed)
390 bar_regen();
391
392 lua_pushboolean( L, (ret==0) || (ret==3) );
393 lua_pushboolean( L, (ret==3) );
394 return 2;
395}
396
407static int naevL_missionTest( lua_State *L )
408{
409 lua_pushboolean( L, mission_test( luaL_checkstring(L, 1) ) );
410 return 1;
411}
412
422static int naevL_eventReload( lua_State *L )
423{
424 const char *str = luaL_checkstring(L, 1);
425 int ret = event_reload( str );
426
427 lua_pushboolean( L, !ret );
428 return 1;
429}
430
440static int naevL_missionReload( lua_State *L )
441{
442 const char *str = luaL_checkstring(L, 1);
443 int ret = mission_reload( str );
444
445 lua_pushboolean( L, !ret );
446 return 1;
447}
448
454static int naevL_shadersReload( lua_State *L )
455{
456 (void) L;
457 shaders_unload();
458 shaders_load();
459 return 0;
460}
461
468static int naevL_isSimulation( lua_State *L )
469{
470 lua_pushboolean( L, space_isSimulation() );
471 return 1;
472}
473
474#define PUSH_STRING( L, name, value ) \
475lua_pushstring( L, name ); \
476lua_pushstring( L, value ); \
477lua_rawset( L, -3 )
478#define PUSH_DOUBLE( L, name, value ) \
479lua_pushstring( L, name ); \
480lua_pushnumber( L, value ); \
481lua_rawset( L, -3 )
482#define PUSH_INT( L, name, value ) \
483lua_pushstring( L, name ); \
484lua_pushinteger( L, value ); \
485lua_rawset( L, -3 )
486#define PUSH_BOOL( L, name, value ) \
487lua_pushstring( L, name ); \
488lua_pushboolean( L, value ); \
489lua_rawset( L, -3 )
496static int naevL_conf( lua_State *L )
497{
498 lua_newtable(L);
499 PUSH_STRING( L, "data", conf.ndata );
500 PUSH_STRING( L, "language", conf.language );
501 PUSH_STRING( L, "difficulty", conf.difficulty );
502 PUSH_INT( L, "fsaa", conf.fsaa );
503 PUSH_BOOL( L, "vsync", conf.vsync );
504 PUSH_INT( L, "width", conf.width );
505 PUSH_INT( L, "height", conf.height );
506 PUSH_DOUBLE( L, "scalefactor", conf.scalefactor );
507 PUSH_DOUBLE( L, "nebu_scale", conf.nebu_scale );
508 PUSH_BOOL( L, "fullscreen", conf.fullscreen );
509 PUSH_BOOL( L, "modesetting", conf.modesetting );
510 PUSH_BOOL( L, "notresizable", conf.notresizable );
511 PUSH_BOOL( L, "borderless", conf.borderless );
512 PUSH_BOOL( L, "minimize", conf.minimize );
513 PUSH_BOOL( L, "colourblind", conf.colourblind );
514 PUSH_DOUBLE( L, "bg_brightness", conf.bg_brightness );
515 PUSH_DOUBLE( L, "nebu_nonuniformity", conf.nebu_nonuniformity );
516 PUSH_DOUBLE( L, "gamma_correction", conf.gamma_correction );
517 PUSH_BOOL( L, "background_fancy", conf.background_fancy );
518 PUSH_BOOL( L, "showfps", conf.fps_show );
519 PUSH_INT( L, "maxfps", conf.fps_max );
520 PUSH_BOOL( L, "showpause", conf.pause_show );
521 PUSH_BOOL( L, "al_efx", conf.al_efx );
522 PUSH_BOOL( L, "nosound", conf.nosound );
523 PUSH_DOUBLE( L, "sound", conf.sound );
524 PUSH_DOUBLE( L, "music", conf.music );
525 /* joystick */
526 PUSH_INT( L, "mesg_visible", conf.mesg_visible );
527 PUSH_DOUBLE( L, "map_overlay_opacity", conf.map_overlay_opacity );
528 PUSH_BOOL( L, "big_icons", conf.big_icons );
529 PUSH_INT( L, "repeat_delay", conf.repeat_delay );
530 PUSH_INT( L, "repeat_freq", conf.repeat_freq );
531 PUSH_BOOL( L, "zoom_manual", conf.zoom_manual );
532 PUSH_DOUBLE( L, "zoom_far", conf.zoom_far );
533 PUSH_DOUBLE( L, "zoom_near", conf.zoom_near );
534 PUSH_DOUBLE( L, "zoom_speed", conf.zoom_speed );
535 PUSH_INT( L, "font_size_console", conf.font_size_console );
536 PUSH_INT( L, "font_size_intro", conf.font_size_intro );
537 PUSH_INT( L, "font_size_def", conf.font_size_def );
538 PUSH_INT( L, "font_size_small", conf.font_size_small );
539 PUSH_BOOL( L, "redirect_file", conf.redirect_file );
540 PUSH_BOOL( L, "save_compress", conf.save_compress );
541 PUSH_INT( L, "doubletap_sensitivity", conf.doubletap_sens );
542 PUSH_DOUBLE( L, "mouse_hide", conf.mouse_hide );
543 PUSH_BOOL( L, "mouse_fly", conf.mouse_fly );
544 PUSH_INT( L, "mouse_accel", conf.mouse_accel );
545 PUSH_DOUBLE( L, "mouse_doubleclick", conf.mouse_doubleclick );
546 PUSH_BOOL( L, "devmode", conf.devmode );
547 PUSH_BOOL( L, "devautosave", conf.devautosave );
548 PUSH_BOOL( L, "lua_enet", conf.lua_enet );
549 PUSH_BOOL( L, "lua_repl", conf.lua_repl );
550 PUSH_BOOL( L, "conf_nosave", conf.nosave );
551 PUSH_STRING( L, "last_version", conf.lastversion );
552 PUSH_BOOL( L, "translation_warning_seen", conf.translation_warning_seen );
553 PUSH_BOOL( L, "fpu_except", conf.fpu_except );
554 PUSH_STRING( L, "dev_save_sys", conf.dev_save_sys );
555 PUSH_STRING( L, "dev_save_map", conf.dev_save_map );
556 PUSH_STRING( L, "dev_save_spob", conf.dev_save_spob );
557 /* TODO remove the following in 0.12.0 */
558 PUSH_DOUBLE( L, "compression_velocity", conf.compression_velocity );
559 PUSH_DOUBLE( L, "compression_mult", conf.compression_mult );
560 PUSH_DOUBLE( L, "autonav_reset_dist", conf.autonav_reset_dist );
561 PUSH_DOUBLE( L, "autonav_reset_shield", conf.autonav_reset_shield );
562 return 1;
563}
564#undef PUSH_STRING
565#undef PUSH_DOUBLE
566#undef PUSH_INT
567#undef PUSH_BOOL
568
576static int naevL_confSet( lua_State *L )
577{
578 (void) L;
579 /* TODO implement. */
580 return NLUA_ERROR(L, _("unimplemented"));
581}
582
592static int naevL_cache( lua_State *L )
593{
594 lua_rawgeti( L, LUA_REGISTRYINDEX, cache_table );
595 return 1;
596}
597
610static int naevL_trigger( lua_State *L )
611{
612 HookParam hp[HOOK_MAX_PARAM];
613 const char *hookname = luaL_checkstring(L,1);
614
615 /* Set up hooks. */
616 if (!lua_isnoneornil(L,2)) {
617 /* Since this doesn't get saved and is triggered by Lua code, we can
618 * actually pass references here. */
619 hp[0].type = HOOK_PARAM_REF;
620 lua_pushvalue(L,2);
621 hp[0].u.ref = luaL_ref( L, LUA_REGISTRYINDEX );
622 hp[1].type = HOOK_PARAM_SENTINEL;
623 }
624 else
625 hp[0].type = HOOK_PARAM_SENTINEL;
626
627 /* Run the deferred hooks. */
628 hooks_runParamDeferred( hookname, hp );
629 return 0;
630}
631
642static int naevL_claimTest( lua_State *L )
643{
644 int inclusive = lua_toboolean(L,2);
645 Claim_t *claim = claim_create( !inclusive );
646
647 if (lua_istable(L,1)) {
648 /* Iterate over table. */
649 lua_pushnil(L);
650 while (lua_next(L, 1) != 0) {
651 if (lua_issystem(L,-1))
652 claim_addSys( claim, lua_tosystem( L, -1 ) );
653 else if (lua_isstring(L,-1))
654 claim_addStr( claim, lua_tostring( L, -1 ) );
655 lua_pop(L,1);
656 }
657 }
658 else if (lua_issystem(L, 1))
659 claim_addSys( claim, lua_tosystem( L, 1 ) );
660 else if (lua_isstring(L, 1))
661 claim_addStr( claim, lua_tostring( L, 1 ) );
662 else
663 NLUA_INVALID_PARAMETER(L,1);
664
665 /* Only test, but don't apply case. */
666 lua_pushboolean( L, !claim_test( claim ) );
667 claim_destroy( claim );
668 return 1;
669}
670
677static int naevL_plugins( lua_State *L )
678{
679 const plugin_t *plugins = plugin_list();
680 lua_newtable(L);
681 for (int i=0; i<array_size(plugins); i++) {
682 const plugin_t *plg = &plugins[i];
683 lua_newtable(L);
684
685#define STRING(x) \
686 lua_pushstring(L,plg->x); \
687 lua_setfield(L,-2,#x)
688#define INTEGER(x) \
689 lua_pushinteger(L,plg->x); \
690 lua_setfield(L,-2,#x)
691#define BOOL(x) \
692 lua_pushboolean(L,plg->x); \
693 lua_setfield(L,-2,#x)
694
695 STRING(name);
696 STRING(author);
697 STRING(version);
698 STRING(description);
699 STRING(compatibility);
700 STRING(mountpoint);
701
702 INTEGER(priority);
703
704 BOOL(compatible);
705 BOOL(total_conversion);
706
707#undef BOOL
708#undef INTEGER
709#undef STRING
710
711 lua_rawseti(L,-2,i+1);
712 }
713 return 1;
714}
715
732static int naevL_menuInfo( lua_State *L )
733{
734 const char *str;
735 int window;
736
737 if (menu_open)
738 return 0;
739
740 if (lua_gettop(L) > 0)
741 str = luaL_checkstring(L,1);
742 else {
743 /* No parameter. */
744 menu_info( INFO_DEFAULT );
745 return 0;
746 }
747
748 /* Parse string. */
749 if (strcasecmp( str, "main" )==0)
750 window = INFO_MAIN;
751 else if (strcasecmp( str, "ship" )==0)
752 window = INFO_SHIP;
753 else if (strcasecmp( str, "weapons" )==0)
754 window = INFO_WEAPONS;
755 else if (strcasecmp( str, "cargo" )==0)
756 window = INFO_CARGO;
757 else if (strcasecmp( str, "missions" )==0)
758 window = INFO_MISSIONS;
759 else if (strcasecmp( str, "standings" )==0)
760 window = INFO_STANDINGS;
761 else
762 return NLUA_ERROR(L,_("Invalid window info name '%s'."), str);
763
764 /* Open window. */
765 menu_info( window );
766
767 return 0;
768}
769
780static int naevL_menuSmall( lua_State *L )
781{
782 menu_small( 0, lua_toboolean(L,1), lua_toboolean(L,2), lua_toboolean(L,3) );
783 return 0;
784}
785
792static int naevL_isPaused( lua_State *L )
793{
794 lua_pushboolean( L, paused );
795 return 1;
796}
797
803static int naevL_pause( lua_State *L )
804{
805 (void) L;
806 pause_game();
807 return 0;
808}
809
817static int naevL_unpause( lua_State *L )
818{
819 if (landed)
820 return NLUA_ERROR(L, _("Unable to unpause the game when landed!"));
821 unpause_game();
822 return 0;
823}
824
831static int naevL_hasTextInput( lua_State *L )
832{
833 lua_pushboolean( L, SDL_EventState( SDL_TEXTINPUT, SDL_QUERY ) == SDL_TRUE );
834 return 1;
835}
836
847static int naevL_setTextInput( lua_State *L )
848{
849 if (lua_toboolean(L,1)) {
850 SDL_Rect input_pos;
851 input_pos.x = luaL_checkinteger(L,2);
852 input_pos.y = luaL_checkinteger(L,3);
853 input_pos.w = luaL_checkinteger(L,4);
854 input_pos.h = luaL_checkinteger(L,5);
855 SDL_EventState( SDL_TEXTINPUT, SDL_ENABLE );
856 SDL_StartTextInput();
857 SDL_SetTextInputRect( &input_pos );
858 }
859 else {
860 SDL_StopTextInput();
861 SDL_EventState( SDL_TEXTINPUT, SDL_DISABLE );
862 }
863 return 0;
864}
865
866static const char *unittbl[] = {
867 "time", _UNIT_TIME,
868 "per_time", _UNIT_PER_TIME,
869 "distance", _UNIT_DISTANCE,
870 "speed", _UNIT_SPEED,
871 "accel", _UNIT_ACCEL,
872 "energy", _UNIT_ENERGY,
873 "power", _UNIT_POWER,
874 "angle", _UNIT_ANGLE,
875 "rotation", _UNIT_ROTATION,
876 "mass", _UNIT_MASS,
877 "cpu", _UNIT_CPU,
878 "unit", _UNIT_UNIT,
879 "percent", _UNIT_PERCENT,
880};
887static int naevL_unit( lua_State *L )
888{
889 if (lua_isnoneornil(L,1)) {
890 lua_newtable( L );
891 for (unsigned int i=0; i<sizeof(unittbl)/sizeof(unittbl[0]); i+=2) {
892 lua_pushstring( L, _(unittbl[i+1]) );
893 lua_setfield( L, -2, unittbl[i] );
894 }
895 return 1;
896 }
897 else {
898 const char *str = luaL_checkstring(L,1);
899 for (unsigned int i=0; i<sizeof(unittbl)/sizeof(unittbl[0]); i+=2) {
900 if (strcmp(unittbl[i],str)==0) {
901 lua_pushstring( L, _(unittbl[i+1]) );
902 return 1;
903 }
904 }
905 }
906 NLUA_INVALID_PARAMETER(L,1);
907}
908
916static int naevL_quadtreeParams( lua_State *L )
917{
918 int max_elem = luaL_checkinteger( L, 1 );
919 int depth = luaL_checkinteger( L, 2 );
920 pilot_quadtreeParams( max_elem, depth );
921 return 0;
922}
923
924#if DEBUGGING
933static int naevL_envs( lua_State *L )
934{
935 nlua_pushEnvTable( L );
936 return 1;
937}
938#endif /* DEBUGGING */
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:168
int claim_test(const Claim_t *claim)
Tests to see if a system claim would have collisions.
Definition claim.c:112
void claim_destroy(Claim_t *claim)
Destroys a system claim.
Definition claim.c:189
int claim_addStr(Claim_t *claim, const char *str)
Adds a string claim to a claim.
Definition claim.c:59
int claim_addSys(Claim_t *claim, int ss_id)
Adds a claim to a system claim.
Definition claim.c:77
Claim_t * claim_create(int exclusive)
Creates a system claim.
Definition claim.c:42
int event_start(const char *name, unsigned int *id)
Starts an event.
Definition event.c:123
const char * gettext_getLanguage(void)
Gets the active (primary) translation language. Even in case of a complex locale, this will be the na...
Definition gettext.c:112
int hooks_runParamDeferred(const char *stack, const HookParam *param)
Runs all the hooks of stack in the next frame. Does not trigger right away.
Definition hook.c:947
Handles the info menu.
#define INFO_SHIP
Definition info.h:9
#define INFO_DEFAULT
Definition info.h:16
#define INFO_CARGO
Definition info.h:11
#define INFO_WEAPONS
Definition info.h:10
#define INFO_STANDINGS
Definition info.h:13
#define INFO_MAIN
Definition info.h:8
#define INFO_MISSIONS
Definition info.h:12
void input_disableAll(void)
Disables all the keybinds.
Definition input.c:346
void input_toggleEnable(const char *key, int enable)
Enables or disables a keybind.
Definition input.c:355
void input_enableAll(void)
Enables all the keybinds.
Definition input.c:337
void input_getKeybindDisplay(const char *keybind, char *buf, int len)
Gets the display name (translated and human-readable) of a keybind.
Definition input.c:453
void bar_regen(void)
Regenerates the bar list.
Definition land.c:382
int landed
Definition land.c:75
Handles the important game menus.
int mission_start(const char *name, unsigned int *id)
Starts a mission.
Definition mission.c:358
const MissionData * mission_list(void)
Returns all the missions.
Definition mission.c:214
int mission_test(const char *name)
Tests the conditionals of a mission.
Definition mission.c:386
double elapsed_time_mod
Definition naev.c:121
double fps_current(void)
Gets the current FPS.
Definition naev.c:984
Header file with generic functions and naev-specifics.
const char * naev_version(int long_version)
Returns the version in a human readable string.
static int naevL_isSimulation(lua_State *L)
Gets whether or not the universe is being simulated or not.
Definition nlua_naev.c:468
static int naevL_menuInfo(lua_State *L)
Opens the info menu window.
Definition nlua_naev.c:732
static int naevL_unit(lua_State *L)
Gets the translated string corresponding to an in-game unit. Lua function parameter:[opt=nil] string ...
Definition nlua_naev.c:887
static int naevL_conf(lua_State *L)
Gets the configuration information.
Definition nlua_naev.c:496
static int naevL_fps(lua_State *L)
Gets the current game FPS as displayed to the player.
Definition nlua_naev.c:268
static int naevL_missionTest(lua_State *L)
Tests a missions conditionals to see if it can be started by the player.
Definition nlua_naev.c:407
static int naevL_eventReload(lua_State *L)
Reloads an event's script, providing a convenient way to test and hopefully not corrupt the game's st...
Definition nlua_naev.c:422
static int naevL_shadersReload(lua_State *L)
Reloads all the Naev shaders excluding those created by the shader library.
Definition nlua_naev.c:454
static int naevL_quadtreeParams(lua_State *L)
Modifies the Naev internal quadtree lookup parameters.
Definition nlua_naev.c:916
static int naevL_lastplayed(lua_State *L)
Gets how many days it has been since the player last played Naev.
Definition nlua_naev.c:213
static int naevL_confSet(lua_State *L)
Sets configuration variables. Note that not all are supported.
Definition nlua_naev.c:576
static int naevL_claimTest(lua_State *L)
Tests a claim of a system or strings.
Definition nlua_naev.c:642
static int naevL_missionStart(lua_State *L)
Starts a mission, does no check start conditions.
Definition nlua_naev.c:384
static int naevL_keyDisableAll(lua_State *L)
Disables all inputs.
Definition nlua_naev.c:331
int nlua_loadNaev(nlua_env env)
Loads the Naev Lua library.
Definition nlua_naev.c:124
static int naevL_keyGet(lua_State *L)
Gets a human-readable name for the key bound to a function.
Definition nlua_naev.c:282
static int naevL_pause(lua_State *L)
Pauses the game.
Definition nlua_naev.c:803
static int naevL_clock(lua_State *L)
Gets the approximate CPU processing time.
Definition nlua_naev.c:256
static int naevL_plugins(lua_State *L)
Gets the list of available plugins.
Definition nlua_naev.c:677
static int naevL_setTextInput(lua_State *L)
Enables or disables text inputting.
Definition nlua_naev.c:847
static int naevL_menuSmall(lua_State *L)
Opens the small menu window.
Definition nlua_naev.c:780
static int naevL_hasTextInput(lua_State *L)
Checks to see if text inputting is enabled.
Definition nlua_naev.c:831
static int naevL_cache(lua_State *L)
Gets the global Lua runtime cache. This is shared among all environments and is cleared when the game...
Definition nlua_naev.c:592
static int naevL_version(lua_State *L)
Naev generic Lua bindings.
Definition nlua_naev.c:152
static int naevL_keyEnableAll(lua_State *L)
Enables all inputs.
Definition nlua_naev.c:318
static int naevL_missionReload(lua_State *L)
Reloads a mission's script, providing a convenient way to test and hopefully not corrupt the game's s...
Definition nlua_naev.c:440
static int naevL_keyEnable(lua_State *L)
Disables or enables a specific keybinding.
Definition nlua_naev.c:303
static int naevL_language(lua_State *L)
Gets the current language locale.
Definition nlua_naev.c:200
static int naevL_ticks(lua_State *L)
Gets the seconds since the program started running.
Definition nlua_naev.c:244
static int naevL_trigger(lua_State *L)
Triggers manually a hook stack. This is run deferred (next frame). Meant mainly to be used with hook....
Definition nlua_naev.c:610
static int naevL_isPaused(lua_State *L)
Checks to see if the game is paused.
Definition nlua_naev.c:792
static int naevL_eventStart(lua_State *L)
Starts an event, does not start check conditions.
Definition nlua_naev.c:346
static int naevL_missionList(lua_State *L)
Lists all the missions in the game.
Definition nlua_naev.c:364
static int naevL_versionTest(lua_State *L)
Tests two semver version strings.
Definition nlua_naev.c:170
static int naevL_unpause(lua_State *L)
Unpauses the game.
Definition nlua_naev.c:817
static int naevL_ticksGame(lua_State *L)
Gets the game seconds since the program started running.
Definition nlua_naev.c:230
static const luaL_Reg naev_methods[]
Definition nlua_naev.c:76
LuaSystem lua_tosystem(lua_State *L, int ind)
Lua system module.
int lua_issystem(lua_State *L, int ind)
Checks to see if ind is a system.
void pause_game(void)
Pauses the game.
Definition pause.c:28
int paused
Definition pause.c:21
void unpause_game(void)
Unpauses the game.
Definition pause.c:46
void pilot_quadtreeParams(int max_elem, int depth)
Sets the quad tree parameters. Can have significant impact on performance.
Definition pilot.c:4177
Player_t player
Definition player.c:74
const plugin_t * plugin_list(void)
Returns the list of all the plugins.
Definition plugin.c:281
static const double d[]
Definition rng.c:273
int space_isSimulation(void)
returns whether we're just simulating.
Definition space.c:1530
The actual hook parameter.
Definition hook.h:38
HookParamType type
Definition hook.h:39
union HookParam::@25 u
int ref
Definition hook.h:52
Static mission data.
Definition mission.h:62
int lua_repl
Definition conf.h:160
int nosound
Definition conf.h:106
double scalefactor
Definition conf.h:89
char * dev_save_map
Definition conf.h:171
int font_size_def
Definition conf.h:141
double autonav_reset_shield
Definition conf.h:156
int colourblind
Definition conf.h:96
int fullscreen
Definition conf.h:91
int vsync
Definition conf.h:83
double compression_velocity
Definition conf.h:146
int modesetting
Definition conf.h:92
int fps_max
Definition conf.h:113
int width
Definition conf.h:86
time_t last_played
Definition conf.h:164
double zoom_speed
Definition conf.h:136
int minimize
Definition conf.h:95
int font_size_small
Definition conf.h:142
char * language
Definition conf.h:79
int devmode
Definition conf.h:157
int pause_show
Definition conf.h:116
int mouse_accel
Definition conf.h:153
int height
Definition conf.h:87
double mouse_hide
Definition conf.h:151
int notresizable
Definition conf.h:93
int big_icons
Definition conf.h:125
unsigned int repeat_freq
Definition conf.h:130
double music
Definition conf.h:108
double mouse_doubleclick
Definition conf.h:154
char * ndata
Definition conf.h:75
double autonav_reset_dist
Definition conf.h:155
int devautosave
Definition conf.h:158
int al_efx
Definition conf.h:105
unsigned int repeat_delay
Definition conf.h:129
char * difficulty
Definition conf.h:145
double compression_mult
Definition conf.h:147
int background_fancy
Definition conf.h:102
int fps_show
Definition conf.h:112
int mesg_visible
Definition conf.h:123
double sound
Definition conf.h:107
double zoom_far
Definition conf.h:134
double gamma_correction
Definition conf.h:101
int nosave
Definition conf.h:161
unsigned int doubletap_sens
Definition conf.h:150
int lua_enet
Definition conf.h:159
double bg_brightness
Definition conf.h:98
int font_size_console
Definition conf.h:139
int zoom_manual
Definition conf.h:133
int save_compress
Definition conf.h:149
int redirect_file
Definition conf.h:148
double map_overlay_opacity
Definition conf.h:124
double nebu_scale
Definition conf.h:90
char * dev_save_spob
Definition conf.h:172
int mouse_fly
Definition conf.h:152
double nebu_nonuniformity
Definition conf.h:99
double zoom_near
Definition conf.h:135
char * lastversion
Definition conf.h:162
int translation_warning_seen
Definition conf.h:163
int fsaa
Definition conf.h:82
int fpu_except
Definition conf.h:167
int borderless
Definition conf.h:94
int font_size_intro
Definition conf.h:140
char * dev_save_sys
Definition conf.h:170
char * loaded_version
Definition player.h:116
time_t last_played
Definition player.h:129