naev 0.11.5
nlua_hook.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
10#include <lauxlib.h>
11#include <lua.h>
12#include <math.h>
13#include <stdio.h>
14#include <stdlib.h>
15
16#include "naev.h"
19#include "nlua_hook.h"
20
21#include "array.h"
22#include "event.h"
23#include "hook.h"
24#include "log.h"
25#include "mission.h"
26#include "nlua_evt.h"
27#include "nlua_misn.h"
28#include "nlua_pilot.h"
29#include "nlua_time.h"
30#include "nluadef.h"
31#include "nstring.h"
32
33/* Hook methods. */
34static int hookL_rm( lua_State *L );
35static int hookL_load( lua_State *L );
36static int hookL_land( lua_State *L );
37static int hookL_info( lua_State *L );
38static int hookL_takeoff( lua_State *L );
39static int hookL_jumpout( lua_State *L );
40static int hookL_jumpin( lua_State *L );
41static int hookL_enter( lua_State *L );
42static int hookL_hail( lua_State *L );
43static int hookL_hail_spob( lua_State *L );
44static int hookL_board( lua_State *L );
45static int hookL_timer( lua_State *L );
46static int hookL_date( lua_State *L );
47static int hookL_commbuy( lua_State *L );
48static int hookL_commsell( lua_State *L );
49static int hookL_commjettison( lua_State *L );
50static int hookL_gather( lua_State *L );
51static int hookL_outfitbuy( lua_State *L );
52static int hookL_outfitsell( lua_State *L );
53static int hookL_shipbuy( lua_State *L );
54static int hookL_shipsell( lua_State *L );
55static int hookL_shipswap( lua_State *L );
56static int hookL_equip( lua_State *L );
57static int hookL_input( lua_State *L );
58static int hookL_mouse( lua_State *L );
59static int hookL_safe( lua_State *L );
60static int hookL_update( lua_State *L );
61static int hookL_renderbg( lua_State *L );
62static int hookL_renderfg( lua_State *L );
63static int hookL_rendertop( lua_State *L );
64static int hookL_mission_done( lua_State *L );
65static int hookL_event_done( lua_State *L );
66static int hookL_standing( lua_State *L );
67static int hookL_discover( lua_State *L );
68static int hookL_asteroidScan( lua_State *L );
69static int hookL_pay( lua_State *L );
70static int hookL_custom( lua_State *L );
71static int hookL_pilot( lua_State *L );
72static const luaL_Reg hookL_methods[] = {
73 { "rm", hookL_rm },
74 { "load", hookL_load },
75 { "land", hookL_land },
76 { "info", hookL_info },
77 { "takeoff", hookL_takeoff },
78 { "jumpout", hookL_jumpout },
79 { "jumpin", hookL_jumpin },
80 { "enter", hookL_enter },
81 { "hail", hookL_hail },
82 { "hail_spob", hookL_hail_spob },
83 { "board", hookL_board },
84 { "timer", hookL_timer },
85 { "date", hookL_date },
86 { "gather", hookL_gather },
87 { "comm_buy", hookL_commbuy },
88 { "comm_sell", hookL_commsell },
89 { "comm_jettison", hookL_commjettison },
90 { "outfit_buy", hookL_outfitbuy },
91 { "outfit_sell", hookL_outfitsell },
92 { "equip", hookL_equip },
93 { "ship_buy", hookL_shipbuy },
94 { "ship_sell", hookL_shipsell },
95 { "ship_swap", hookL_shipswap },
96 { "input", hookL_input },
97 { "mouse", hookL_mouse },
98 { "safe", hookL_safe },
99 { "update", hookL_update },
100 { "renderbg", hookL_renderbg },
101 { "renderfg", hookL_renderfg },
102 { "rendertop", hookL_rendertop },
103 { "mission_done", hookL_mission_done },
104 { "event_done", hookL_event_done },
105 { "standing", hookL_standing },
106 { "discover", hookL_discover },
107 { "asteroid_scan", hookL_asteroidScan },
108 { "pay", hookL_pay },
109 { "custom", hookL_custom },
110 { "pilot", hookL_pilot },
111 {0,0}
112};
114/*
115 * Prototypes.
116 */
117static int hookL_setarg( unsigned int hook, int ind );
118static unsigned int hookL_generic( lua_State *L, const char* stack, double ms, int pos, ntime_t date, int arg );
119
125int nlua_loadHook( nlua_env env )
126{
127 nlua_register(env, "hook", hookL_methods, 0);
128 return 0;
129}
130
160static int hookL_rm( lua_State *L )
161{
162 /* Remove the hook. */
163 long h = luaL_optlong( L, 1, -1 );
164 /* ... Or do a no-op if caller passes nil. */
165 if (h < 0)
166 return 0;
167 hook_rm( (unsigned int) h );
168 return 0;
169}
170
178static int hookL_setarg( unsigned int hook, int ind )
179{
180 nlua_env env = hook_env(hook);
181
182 /* Create if necessary the actual hook argument table. */
183 nlua_getenv(naevL, env, "mem"); /* t */
184 lua_getfield(naevL, -1, "__hook_arg"); /* t, t */
185 if (lua_isnil(naevL,-1)) { /* t, nil */
186 lua_pop( naevL, 1 ); /* t */
187 lua_newtable( naevL ); /* t, t */
188 lua_pushvalue( naevL, -1 ); /* t, t, t */
189 lua_setfield(naevL, -3, "__hook_arg"); /* t, t */
190 }
191 lua_pushinteger( naevL, hook ); /*t, t, k */
192 lua_pushvalue( naevL, ind ); /*t, t, k, v */
193 lua_settable( naevL, -3 ); /*t, t */
194 lua_pop( naevL, 2 ); /* */
195 return 0;
196}
197
201void hookL_unsetarg( unsigned int hook )
202{
203 nlua_env env = hook_env(hook);
204
205 if (env == LUA_NOREF)
206 return;
207
208 nlua_getenv(naevL, env, "mem"); /* t */
209 lua_getfield(naevL, -1, "__hook_arg"); /* t, t */
210 if (!lua_isnil(naevL,-1)) {
211 lua_pushinteger( naevL, hook ); /* t, h */
212 lua_pushnil( naevL ); /* t, h, n */
213 lua_settable( naevL, -3 ); /* t */
214 }
215 lua_pop( naevL, 2 );
216}
217
224int hookL_getarg( unsigned int hook )
225{
226 nlua_env env = hook_env(hook);
227
228 if (env == LUA_NOREF)
229 return 0;
230
231 nlua_getenv(naevL, env, "mem"); /* t */
232 lua_getfield(naevL, -1, "__hook_arg");/* t, t */
233 if (!lua_isnil(naevL,-1)) { /* t, t */
234 lua_pushinteger( naevL, hook ); /* t, t, k */
235 lua_gettable( naevL, -2 ); /* t, t, v */
236 lua_remove( naevL, -2 ); /* t, v */
237 }
238 lua_remove( naevL, -2 ); /* v */
239 return 1;
240}
241
255static unsigned int hookL_generic( lua_State *L, const char* stack, double sec, int pos, ntime_t date, int arg )
256{
257 const char *func;
258 unsigned int h;
259 Event_t *running_event;
260 Mission *running_mission;
261
262 /* Last parameter must be function to hook */
263 func = luaL_checkstring(L,pos);
264
265 /* Get stuff. */
266 running_event = event_getFromLua(L);
267 running_mission = misn_getFromLua(L);
268
269 if (running_mission != NULL) {
270 int i;
271 /* make sure mission is a player mission */
272 for (i=0; i<array_size(player_missions); i++)
273 if (player_missions[i]->id == running_mission->id)
274 break;
275 if (i>=array_size(player_missions)) {
276 WARN(_("Mission not in stack trying to hook, forgot to run misn.accept()?"));
277 return 0;
278 }
279
280 if (stack != NULL)
281 h = hook_addMisn( running_mission->id, func, stack );
282 else if (date != 0)
283 h = hook_addDateMisn( running_mission->id, func, date );
284 else
285 h = hook_addTimerMisn( running_mission->id, func, sec );
286 }
287 else if (running_event != NULL) {
288 if (stack != NULL)
289 h = hook_addEvent( running_event->id, func, stack );
290 else if (date != 0)
291 h = hook_addDateEvt( running_event->id, func, date );
292 else
293 h = hook_addTimerEvt( running_event->id, func, sec );
294 }
295 else
296 return NLUA_ERROR(L,_("Attempting to set a hook outside of a mission or event."));
297
298 if (h == 0)
299 return NLUA_ERROR(L,_("No hook target was set."));
300
301 /* Check parameter. */
302 if (!lua_isnoneornil(L,arg))
303 hookL_setarg( h, arg );
304
305 return h;
306}
307
330static int hookL_land( lua_State *L )
331{
332 unsigned int h;
333
334 if (lua_isstring(L,2)) {
335 const char *where = luaL_checkstring(L, 2);
336 /* TODO validity checking? */
337 h = hookL_generic( L, where, 0., 1, 0, 3 );
338 }
339 else
340 h = hookL_generic( L, "land", 0., 1, 0, 2 );
341
342 lua_pushinteger( L, h );
343 return 1;
344}
345
368static int hookL_info( lua_State *L )
369{
370 unsigned int h;
371
372 if (lua_isstring(L,2)) {
373 char buf[STRMAX_SHORT];
374 const char *where = luaL_checkstring(L, 2);
375 snprintf( buf, sizeof(buf), "info_%s", where );
376 /* TODO validity checking? */
377 h = hookL_generic( L, buf, 0., 1, 0, 3 );
378 }
379 else
380 h = hookL_generic( L, "info", 0., 1, 0, 2 );
381
382 lua_pushinteger( L, h );
383 return 1;
384}
385
396static int hookL_load( lua_State *L )
397{
398 unsigned int h = hookL_generic( L, "load", 0., 1, 0, 2 );
399 lua_pushinteger( L, h );
400 return 1;
401}
402
411static int hookL_takeoff( lua_State *L )
412{
413 unsigned int h = hookL_generic( L, "takeoff", 0., 1, 0, 2 );
414 lua_pushinteger( L, h );
415 return 1;
416}
417
426static int hookL_jumpout( lua_State *L )
427{
428 unsigned int h = hookL_generic( L, "jumpout", 0., 1, 0, 2 );
429 lua_pushinteger( L, h );
430 return 1;
431}
432
441static int hookL_jumpin( lua_State *L )
442{
443 unsigned int h = hookL_generic( L, "jumpin", 0., 1, 0, 2 );
444 lua_pushinteger( L, h );
445 return 1;
446}
447
457static int hookL_enter( lua_State *L )
458{
459 unsigned int h = hookL_generic( L, "enter", 0., 1, 0, 2 );
460 lua_pushinteger( L, h );
461 return 1;
462}
463
474static int hookL_hail_spob( lua_State *L )
475{
476 unsigned int h = hookL_generic( L, "hail_spob", 0., 1, 0, 2 );
477 lua_pushinteger( L, h );
478 return 1;
479}
480
491static int hookL_hail( lua_State *L )
492{
493 unsigned int h = hookL_generic( L, "hail", 0., 1, 0, 2 );
494 lua_pushinteger( L, h );
495 return 1;
496}
497
508static int hookL_board( lua_State *L )
509{
510 unsigned int h = hookL_generic( L, "board", 0., 1, 0, 2 );
511 lua_pushinteger( L, h );
512 return 1;
513}
514
526static int hookL_timer( lua_State *L )
527{
528 double s = luaL_checknumber( L, 1 );
529 unsigned int h = hookL_generic( L, NULL, s, 2, 0, 3 );
530 lua_pushinteger( L, h );
531 return 1;
532}
533
547static int hookL_date( lua_State *L )
548{
549 ntime_t t = luaL_validtime( L, 1 );
550 unsigned int h = hookL_generic( L, NULL, 0., 2, t, 3 );
551 lua_pushinteger( L, h );
552 return 1;
553}
554
565static int hookL_commbuy( lua_State *L )
566{
567 unsigned int h = hookL_generic( L, "comm_buy", 0., 1, 0, 2 );
568 lua_pushinteger( L, h );
569 return 1;
570}
571
582static int hookL_commsell( lua_State *L )
583{
584 unsigned int h = hookL_generic( L, "comm_sell", 0., 1, 0, 2 );
585 lua_pushinteger( L, h );
586 return 1;
587}
588
599static int hookL_commjettison( lua_State *L )
600{
601 unsigned int h = hookL_generic( L, "comm_jettison", 0., 1, 0, 2 );
602 lua_pushinteger( L, h );
603 return 1;
604}
605
616static int hookL_gather( lua_State *L )
617{
618 unsigned int h = hookL_generic( L, "gather", 0., 1, 0, 2 );
619 lua_pushinteger( L, h );
620 return 1;
621}
622
633static int hookL_outfitbuy( lua_State *L )
634{
635 unsigned int h = hookL_generic( L, "outfit_buy", 0., 1, 0, 2 );
636 lua_pushinteger( L, h );
637 return 1;
638}
639
650static int hookL_outfitsell( lua_State *L )
651{
652 unsigned int h = hookL_generic( L, "outfit_sell", 0., 1, 0, 2 );
653 lua_pushinteger( L, h );
654 return 1;
655}
656
665static int hookL_equip( lua_State *L )
666{
667 unsigned int h = hookL_generic( L, "equip", 0., 1, 0, 2 );
668 lua_pushinteger( L, h );
669 return 1;
670}
671
682static int hookL_shipbuy( lua_State *L )
683{
684 unsigned int h = hookL_generic( L, "ship_buy", 0., 1, 0, 2 );
685 lua_pushinteger( L, h );
686 return 1;
687}
688
699static int hookL_shipsell( lua_State *L )
700{
701 unsigned int h = hookL_generic( L, "ship_sell", 0., 1, 0, 2 );
702 lua_pushinteger( L, h );
703 return 1;
704}
705
716static int hookL_shipswap( lua_State *L )
717{
718 unsigned int h = hookL_generic( L, "ship_swap", 0., 1, 0, 2 );
719 lua_pushinteger( L, h );
720 return 1;
721}
722
736static int hookL_input( lua_State *L )
737{
738 unsigned int h = hookL_generic( L, "input", 0., 1, 0, 2 );
739 lua_pushinteger( L, h );
740 return 1;
741}
742
753static int hookL_mouse( lua_State *L )
754{
755 unsigned int h = hookL_generic( L, "mouse", 0., 1, 0, 2 );
756 lua_pushinteger( L, h );
757 return 1;
758}
759
772static int hookL_standing( lua_State *L )
773{
774 unsigned int h = hookL_generic( L, "standing", 0., 1, 0, 2 );
775 lua_pushinteger( L, h );
776 return 1;
777}
778
793static int hookL_discover( lua_State *L )
794{
795 unsigned int h = hookL_generic( L, "discover", 0., 1, 0, 2 );
796 lua_pushinteger( L, h );
797 return 1;
798}
799
810static int hookL_asteroidScan( lua_State *L )
811{
812 unsigned int h = hookL_generic( L, "asteroid_scan", 0., 1, 0, 2 );
813 lua_pushinteger( L, h );
814 return 1;
815}
816
828static int hookL_pay( lua_State *L )
829{
830 unsigned int h = hookL_generic( L, "pay", 0., 1, 0, 2 );
831 lua_pushinteger( L, h );
832 return 1;
833}
834
845static int hookL_safe( lua_State *L )
846{
847 unsigned int h = hookL_generic( L, "safe", 0., 1, 0, 2 );
848 lua_pushinteger( L, h );
849 return 1;
850}
851
865static int hookL_update( lua_State *L )
866{
867 unsigned int h = hookL_generic( L, "update", 0., 1, 0, 2 );
868 lua_pushinteger( L, h );
869 return 1;
870}
871
880static int hookL_renderbg( lua_State *L )
881{
882 unsigned int h = hookL_generic( L, "renderbg", 0., 1, 0, 2 );
883 lua_pushinteger( L, h );
884 return 1;
885}
886
895static int hookL_renderfg( lua_State *L )
896{
897 unsigned int h = hookL_generic( L, "renderfg", 0., 1, 0, 2 );
898 lua_pushinteger( L, h );
899 return 1;
900}
901
910static int hookL_rendertop( lua_State *L )
911{
912 unsigned int h = hookL_generic( L, "rendertop", 0., 1, 0, 2 );
913 lua_pushinteger( L, h );
914 return 1;
915}
916
925static int hookL_mission_done( lua_State *L )
926{
927 unsigned int h = hookL_generic( L, "mission_done", 0., 1, 0, 2 );
928 lua_pushinteger( L, h );
929 return 1;
930}
931
940static int hookL_event_done( lua_State *L )
941{
942 unsigned int h = hookL_generic( L, "event_done", 0., 1, 0, 2 );
943 lua_pushinteger( L, h );
944 return 1;
945}
946
956static int hookL_custom( lua_State *L )
957{
958 const char *hookname = luaL_checkstring(L,1);
959 unsigned int h = hookL_generic( L, hookname, 0., 2, 0, 3 );
960 lua_pushinteger( L, h );
961 return 1;
962}
963
1033static int hookL_pilot( lua_State *L )
1034{
1035 unsigned int h;
1036 LuaPilot p;
1037 int type;
1038 const char *hook_type;
1039 char buf[64]; /* Large enough buffer to hold any of the allowed hook-type names. */
1040
1041 /* Parameters. */
1042 if (lua_ispilot(L,1))
1043 p = luaL_checkpilot(L,1);
1044 else if (lua_isnil(L,1))
1045 p = 0;
1046 else
1047 return NLUA_ERROR(L, _("Invalid parameter #1 for hook.pilot, expecting pilot or nil."));
1048 hook_type = luaL_checkstring(L,2);
1049
1050 /* Check to see if hook_type is valid */
1051 if (strcmp(hook_type,"creation")==0) type = PILOT_HOOK_CREATION;
1052 else if (strcmp(hook_type,"death")==0) type = PILOT_HOOK_DEATH;
1053 else if (strcmp(hook_type,"exploded")==0) type = PILOT_HOOK_EXPLODED;
1054 else if (strcmp(hook_type,"boarding")==0) type = PILOT_HOOK_BOARDING;
1055 else if (strcmp(hook_type,"boardall")==0) type = PILOT_HOOK_BOARD_ALL;
1056 else if (strcmp(hook_type,"board")==0) type = PILOT_HOOK_BOARD;
1057 else if (strcmp(hook_type,"disable")==0) type = PILOT_HOOK_DISABLE;
1058 else if (strcmp(hook_type,"undisable")==0)type = PILOT_HOOK_UNDISABLE;
1059 else if (strcmp(hook_type,"jump")==0) type = PILOT_HOOK_JUMP;
1060 else if (strcmp(hook_type,"hail")==0) type = PILOT_HOOK_HAIL;
1061 else if (strcmp(hook_type,"land")==0) type = PILOT_HOOK_LAND;
1062 else if (strcmp(hook_type,"attacked")==0) type = PILOT_HOOK_ATTACKED;
1063 else if (strcmp(hook_type,"discovered")==0)type = PILOT_HOOK_DISCOVERED;
1064 else if (strcmp(hook_type,"scan")==0) type = PILOT_HOOK_SCAN;
1065 else if (strcmp(hook_type,"scanned")==0) type = PILOT_HOOK_SCANNED;
1066 else if (strcmp(hook_type,"idle")==0) type = PILOT_HOOK_IDLE;
1067 else if (strcmp(hook_type,"lockon")==0) type = PILOT_HOOK_LOCKON;
1068 else if (strcmp(hook_type,"stealth")==0) type = PILOT_HOOK_STEALTH;
1069 else /* hook_type not valid */
1070 return NLUA_ERROR(L, _("Invalid pilot hook type: '%s'"), hook_type);
1071
1072#ifdef DEBUGGING
1073 if ((type == PILOT_HOOK_CREATION) && (p!=0))
1074 return NLUA_ERROR( L, _("'creation' pilot hook can not be set on a specific pilot, only globally.") );
1075#endif /* DEBUGGING */
1076
1077 /* actually add the hook */
1078 snprintf( buf, sizeof(buf), "p_%s", hook_type );
1079 h = hookL_generic( L, buf, 0., 3, 0, 4 );
1080 if (p==0)
1081 pilots_addGlobalHook( type, h );
1082 else
1083 pilot_addHook( pilot_get(p), type, h );
1084
1085 lua_pushinteger( L, h );
1086 return 1;
1087}
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
unsigned int hook_addTimerEvt(unsigned int parent, const char *func, double ms)
Adds a new event type hook timer.
Definition hook.c:575
nlua_env hook_env(unsigned int hook)
Gets the lua env for a hook.
Definition hook.c:1019
unsigned int hook_addEvent(unsigned int parent, const char *func, const char *stack)
Adds a new event type hook.
Definition hook.c:531
void hook_rm(unsigned int id)
Removes a hook.
Definition hook.c:798
unsigned int hook_addTimerMisn(unsigned int parent, const char *func, double ms)
Adds a new mission type hook timer hook.
Definition hook.c:551
unsigned int hook_addMisn(unsigned int parent, const char *func, const char *stack)
Adds a new mission type hook.
Definition hook.c:511
Mission ** player_missions
Definition mission.c:47
Header file with generic functions and naev-specifics.
Event_t * event_getFromLua(lua_State *L)
Gets the current running event from user data.
Definition nlua_evt.c:114
static int hookL_date(lua_State *L)
Hooks a date change with custom resolution.
Definition nlua_hook.c:547
static int hookL_rm(lua_State *L)
Lua bindings to manipulate hooks.
Definition nlua_hook.c:160
static int hookL_discover(lua_State *L)
Hooks the function to when the player discovers an spob, jump point or the likes.
Definition nlua_hook.c:793
static int hookL_load(lua_State *L)
Hooks the function to the player loading the game (starts landed).
Definition nlua_hook.c:396
static int hookL_custom(lua_State *L)
Hook run once at the end of the next frame regardless when manually triggered. Can be triggered manua...
Definition nlua_hook.c:956
static int hookL_hail(lua_State *L)
Hooks the function to the player hailing any ship (not a spob).
Definition nlua_hook.c:491
void hookL_unsetarg(unsigned int hook)
Unsets a Lua argument.
Definition nlua_hook.c:201
static int hookL_gather(lua_State *L)
Hooks the function to the player gatehring any sort of commodity in space.
Definition nlua_hook.c:616
static int hookL_renderfg(lua_State *L)
Hook that runs during rendering the foreground (just below the gui stuff). Meant to be only for rende...
Definition nlua_hook.c:895
static int hookL_shipbuy(lua_State *L)
Hooks the function to the player buying any sort of ship.
Definition nlua_hook.c:682
static int hookL_timer(lua_State *L)
Hooks a timer.
Definition nlua_hook.c:526
static int hookL_pilot(lua_State *L)
Hooks the function to a specific pilot.
Definition nlua_hook.c:1033
static int hookL_outfitbuy(lua_State *L)
Hooks the function to the player buying any sort of outfit.
Definition nlua_hook.c:633
static int hookL_hail_spob(lua_State *L)
Hooks the function to the player hailing any spob.
Definition nlua_hook.c:474
static unsigned int hookL_generic(lua_State *L, const char *stack, double ms, int pos, ntime_t date, int arg)
Creates a mission hook to a certain stack.
Definition nlua_hook.c:255
static int hookL_input(lua_State *L)
Hooks the function to the player pressing any input.
Definition nlua_hook.c:736
int nlua_loadHook(nlua_env env)
Loads the hook Lua library.
Definition nlua_hook.c:125
static int hookL_asteroidScan(lua_State *L)
Hooks the function to when the player scans an asteroid.
Definition nlua_hook.c:810
static int hookL_jumpin(lua_State *L)
Hooks the function to the player jumping (after changing systems).
Definition nlua_hook.c:441
static int hookL_info(lua_State *L)
Hooks the function to the info menu.
Definition nlua_hook.c:368
static int hookL_board(lua_State *L)
Hooks the function to the player boarding any ship.
Definition nlua_hook.c:508
static int hookL_rendertop(lua_State *L)
Hook that runs during rendering aove everything. Meant to be as an alternative to doing post-processi...
Definition nlua_hook.c:910
static int hookL_setarg(unsigned int hook, int ind)
Sets a Lua argument for a hook.
Definition nlua_hook.c:178
static int hookL_equip(lua_State *L)
Hooks the function to the player equipping or deequipping any outfit.
Definition nlua_hook.c:665
static int hookL_commsell(lua_State *L)
Hooks the function to the player selling any sort of commodity.
Definition nlua_hook.c:582
static int hookL_safe(lua_State *L)
Hook run once at the end of the next frame regardless of anything that can happen.
Definition nlua_hook.c:845
static int hookL_shipsell(lua_State *L)
Hooks the function to the player selling any sort of ship.
Definition nlua_hook.c:699
static int hookL_land(lua_State *L)
Hooks the function to the player landing.
Definition nlua_hook.c:330
static int hookL_standing(lua_State *L)
Hooks the function to any faction standing change.
Definition nlua_hook.c:772
static const luaL_Reg hookL_methods[]
Definition nlua_hook.c:72
static int hookL_takeoff(lua_State *L)
Hooks the function to the player taking off.
Definition nlua_hook.c:411
static int hookL_commjettison(lua_State *L)
Hooks the function to the player jettisoning any sort of commodity.
Definition nlua_hook.c:599
static int hookL_commbuy(lua_State *L)
Hooks the function to the player buying any sort of commodity.
Definition nlua_hook.c:565
static int hookL_outfitsell(lua_State *L)
Hooks the function to the player selling any sort of outfit.
Definition nlua_hook.c:650
static int hookL_event_done(lua_State *L)
Hook that runs when a event is complete. The entire event information table is passed similar to play...
Definition nlua_hook.c:940
static int hookL_shipswap(lua_State *L)
Hooks the function to the player swapping their ship.
Definition nlua_hook.c:716
static int hookL_pay(lua_State *L)
Hooks the function to when the player receives or loses money through player.pay() (the Lua function ...
Definition nlua_hook.c:828
static int hookL_renderbg(lua_State *L)
Hook that runs during rendering the background (just above the static background stuff)....
Definition nlua_hook.c:880
int hookL_getarg(unsigned int hook)
Gets a Lua argument for a hook.
Definition nlua_hook.c:224
static int hookL_enter(lua_State *L)
Hooks the function to the player entering a system (triggers when taking off too).
Definition nlua_hook.c:457
static int hookL_mission_done(lua_State *L)
Hook that runs when a mission is complete. The entire mission information table is passed similar to ...
Definition nlua_hook.c:925
static int hookL_mouse(lua_State *L)
Hooks the function to the player clicking the mouse.
Definition nlua_hook.c:753
static int hookL_jumpout(lua_State *L)
Hooks the function to the player jumping (before changing systems).
Definition nlua_hook.c:426
static int hookL_update(lua_State *L)
Hook run at the end of each frame when the update routine is run (game is not paused,...
Definition nlua_hook.c:865
Mission * misn_getFromLua(lua_State *L)
Gets the mission that's being currently run in Lua.
Definition nlua_misn.c:180
int lua_ispilot(lua_State *L, int ind)
Checks to see if ind is a pilot.
Definition nlua_pilot.c:578
LuaPilot luaL_checkpilot(lua_State *L, int ind)
Gets pilot at index or raises error if there is no pilot at index.
Definition nlua_pilot.c:533
ntime_t luaL_validtime(lua_State *L, int ind)
Gets a time directly.
Definition nlua_time.c:115
Pilot * pilot_get(unsigned int id)
Pulls a pilot out of the pilot_stack based on ID.
Definition pilot.c:620
void pilots_addGlobalHook(int type, unsigned int hook)
Adds a pilot global hook.
Definition pilot_hook.c:135
void pilot_addHook(Pilot *pilot, int type, unsigned int hook)
Adds a hook to the pilot.
Definition pilot_hook.c:118
Activated event structure.
Definition event.h:12
unsigned int id
Definition event.h:13
Represents an active mission.
Definition mission.h:81
unsigned int id
Definition mission.h:83