naev 0.10.4
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_board( lua_State *L );
44static int hookL_timer( lua_State *L );
45static int hookL_date( lua_State *L );
46static int hookL_commbuy( lua_State *L );
47static int hookL_commsell( lua_State *L );
48static int hookL_commjettison( lua_State *L );
49static int hookL_gather( lua_State *L );
50static int hookL_outfitbuy( lua_State *L );
51static int hookL_outfitsell( lua_State *L );
52static int hookL_shipbuy( lua_State *L );
53static int hookL_shipsell( lua_State *L );
54static int hookL_shipswap( lua_State *L );
55static int hookL_equip( lua_State *L );
56static int hookL_input( lua_State *L );
57static int hookL_mouse( lua_State *L );
58static int hookL_safe( lua_State *L );
59static int hookL_update( lua_State *L );
60static int hookL_renderbg( lua_State *L );
61static int hookL_renderfg( lua_State *L );
62static int hookL_rendertop( lua_State *L );
63static int hookL_mission_done( lua_State *L );
64static int hookL_standing( lua_State *L );
65static int hookL_discover( lua_State *L );
66static int hookL_asteroidScan( lua_State *L );
67static int hookL_pay( lua_State *L );
68static int hookL_custom( lua_State *L );
69static int hookL_pilot( lua_State *L );
70static const luaL_Reg hookL_methods[] = {
71 { "rm", hookL_rm },
72 { "load", hookL_load },
73 { "land", hookL_land },
74 { "info", hookL_info },
75 { "takeoff", hookL_takeoff },
76 { "jumpout", hookL_jumpout },
77 { "jumpin", hookL_jumpin },
78 { "enter", hookL_enter },
79 { "hail", hookL_hail },
80 { "board", hookL_board },
81 { "timer", hookL_timer },
82 { "date", hookL_date },
83 { "gather", hookL_gather },
84 { "comm_buy", hookL_commbuy },
85 { "comm_sell", hookL_commsell },
86 { "comm_jettison", hookL_commjettison },
87 { "outfit_buy", hookL_outfitbuy },
88 { "outfit_sell", hookL_outfitsell },
89 { "equip", hookL_equip },
90 { "ship_buy", hookL_shipbuy },
91 { "ship_sell", hookL_shipsell },
92 { "ship_swap", hookL_shipswap },
93 { "input", hookL_input },
94 { "mouse", hookL_mouse },
95 { "safe", hookL_safe },
96 { "update", hookL_update },
97 { "renderbg", hookL_renderbg },
98 { "renderfg", hookL_renderfg },
99 { "rendertop", hookL_rendertop },
100 { "mission_done", hookL_mission_done },
101 { "standing", hookL_standing },
102 { "discover", hookL_discover },
103 { "asteroid_scan", hookL_asteroidScan },
104 { "pay", hookL_pay },
105 { "custom", hookL_custom },
106 { "pilot", hookL_pilot },
107 {0,0}
108};
110/*
111 * Prototypes.
112 */
113static int hookL_setarg( unsigned int hook, int ind );
114static unsigned int hookL_generic( lua_State *L, const char* stack, double ms, int pos, ntime_t date, int arg );
115
121int nlua_loadHook( nlua_env env )
122{
123 nlua_register(env, "hook", hookL_methods, 0);
124 return 0;
125}
126
156static int hookL_rm( lua_State *L )
157{
158 /* Remove the hook. */
159 long h = luaL_optlong( L, 1, -1 );
160 /* ... Or do a no-op if caller passes nil. */
161 if (h < 0)
162 return 0;
163 hook_rm( (unsigned int) h );
164 return 0;
165}
166
174static int hookL_setarg( unsigned int hook, int ind )
175{
176 nlua_env env = hook_env(hook);
177
178 /* Create if necessary the actual hook argument table. */
179 nlua_getenv(naevL, env, "mem"); /* t */
180 lua_getfield(naevL, -1, "__hook_arg"); /* t, t */
181 if (lua_isnil(naevL,-1)) { /* t, nil */
182 lua_pop( naevL, 1 ); /* t */
183 lua_newtable( naevL ); /* t, t */
184 lua_pushvalue( naevL, -1 ); /* t, t, t */
185 lua_setfield(naevL, -3, "__hook_arg"); /* t, t */
186 }
187 lua_pushnumber( naevL, hook ); /*t, t, k */
188 lua_pushvalue( naevL, ind ); /*t, t, k, v */
189 lua_settable( naevL, -3 ); /*t, t */
190 lua_pop( naevL, 2 ); /* */
191 return 0;
192}
193
197void hookL_unsetarg( unsigned int hook )
198{
199 nlua_env env = hook_env(hook);
200
201 if (env == LUA_NOREF)
202 return;
203
204 nlua_getenv(naevL, env, "mem"); /* t */
205 lua_getfield(naevL, -1, "__hook_arg"); /* t, t */
206 if (!lua_isnil(naevL,-1)) {
207 lua_pushnumber( naevL, hook ); /* t, h */
208 lua_pushnil( naevL ); /* t, h, n */
209 lua_settable( naevL, -3 ); /* t */
210 }
211 lua_pop( naevL, 2 );
212}
213
220int hookL_getarg( unsigned int hook )
221{
222 nlua_env env = hook_env(hook);
223
224 if (env == LUA_NOREF)
225 return 0;
226
227 nlua_getenv(naevL, env, "mem"); /* t */
228 lua_getfield(naevL, -1, "__hook_arg");/* t, t */
229 if (!lua_isnil(naevL,-1)) { /* t, t */
230 lua_pushnumber( naevL, hook ); /* t, t, k */
231 lua_gettable( naevL, -2 ); /* t, t, v */
232 lua_remove( naevL, -2 ); /* t, v */
233 }
234 lua_remove( naevL, -2 ); /* v */
235 return 1;
236}
237
251static unsigned int hookL_generic( lua_State *L, const char* stack, double sec, int pos, ntime_t date, int arg )
252{
253 const char *func;
254 unsigned int h;
255 Event_t *running_event;
256 Mission *running_mission;
257
258 /* Last parameter must be function to hook */
259 func = luaL_checkstring(L,pos);
260
261 /* Get stuff. */
262 running_event = event_getFromLua(L);
263 running_mission = misn_getFromLua(L);
264
265 if (running_mission != NULL) {
266 int i;
267 /* make sure mission is a player mission */
268 for (i=0; i<array_size(player_missions); i++)
269 if (player_missions[i]->id == running_mission->id)
270 break;
271 if (i>=array_size(player_missions)) {
272 WARN(_("Mission not in stack trying to hook, forgot to run misn.accept()?"));
273 return 0;
274 }
275
276 if (stack != NULL)
277 h = hook_addMisn( running_mission->id, func, stack );
278 else if (date != 0)
279 h = hook_addDateMisn( running_mission->id, func, date );
280 else
281 h = hook_addTimerMisn( running_mission->id, func, sec );
282 }
283 else if (running_event != NULL) {
284 if (stack != NULL)
285 h = hook_addEvent( running_event->id, func, stack );
286 else if (date != 0)
287 h = hook_addDateEvt( running_event->id, func, date );
288 else
289 h = hook_addTimerEvt( running_event->id, func, sec );
290 }
291 else {
292 NLUA_ERROR(L,_("Attempting to set a hook outside of a mission or event."));
293 return 0;
294 }
295
296 if (h == 0) {
297 NLUA_ERROR(L,_("No hook target was set."));
298 return 0;
299 }
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_pushnumber( 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_pushnumber( 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_pushnumber( 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_pushnumber( 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_pushnumber( 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_pushnumber( 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_pushnumber( L, h );
461 return 1;
462}
463
474static int hookL_hail( lua_State *L )
475{
476 unsigned int h = hookL_generic( L, "hail", 0., 1, 0, 2 );
477 lua_pushnumber( L, h );
478 return 1;
479}
480
491static int hookL_board( lua_State *L )
492{
493 unsigned int h = hookL_generic( L, "board", 0., 1, 0, 2 );
494 lua_pushnumber( L, h );
495 return 1;
496}
497
509static int hookL_timer( lua_State *L )
510{
511 double s = luaL_checknumber( L, 1 );
512 unsigned int h = hookL_generic( L, NULL, s, 2, 0, 3 );
513 lua_pushnumber( L, h );
514 return 1;
515}
516
530static int hookL_date( lua_State *L )
531{
532 ntime_t t = luaL_validtime( L, 1 );
533 unsigned int h = hookL_generic( L, NULL, 0., 2, t, 3 );
534 lua_pushnumber( L, h );
535 return 1;
536}
537
548static int hookL_commbuy( lua_State *L )
549{
550 unsigned int h = hookL_generic( L, "comm_buy", 0., 1, 0, 2 );
551 lua_pushnumber( L, h );
552 return 1;
553}
554
565static int hookL_commsell( lua_State *L )
566{
567 unsigned int h = hookL_generic( L, "comm_sell", 0., 1, 0, 2 );
568 lua_pushnumber( L, h );
569 return 1;
570}
571
582static int hookL_commjettison( lua_State *L )
583{
584 unsigned int h = hookL_generic( L, "comm_jettison", 0., 1, 0, 2 );
585 lua_pushnumber( L, h );
586 return 1;
587}
588
599static int hookL_gather( lua_State *L )
600{
601 unsigned int h = hookL_generic( L, "gather", 0., 1, 0, 2 );
602 lua_pushnumber( L, h );
603 return 1;
604}
605
616static int hookL_outfitbuy( lua_State *L )
617{
618 unsigned int h = hookL_generic( L, "outfit_buy", 0., 1, 0, 2 );
619 lua_pushnumber( L, h );
620 return 1;
621}
622
633static int hookL_outfitsell( lua_State *L )
634{
635 unsigned int h = hookL_generic( L, "outfit_sell", 0., 1, 0, 2 );
636 lua_pushnumber( L, h );
637 return 1;
638}
639
648static int hookL_equip( lua_State *L )
649{
650 unsigned int h = hookL_generic( L, "equip", 0., 1, 0, 2 );
651 lua_pushnumber( L, h );
652 return 1;
653}
654
665static int hookL_shipbuy( lua_State *L )
666{
667 unsigned int h = hookL_generic( L, "ship_buy", 0., 1, 0, 2 );
668 lua_pushnumber( L, h );
669 return 1;
670}
671
682static int hookL_shipsell( lua_State *L )
683{
684 unsigned int h = hookL_generic( L, "ship_sell", 0., 1, 0, 2 );
685 lua_pushnumber( L, h );
686 return 1;
687}
688
699static int hookL_shipswap( lua_State *L )
700{
701 unsigned int h = hookL_generic( L, "ship_swap", 0., 1, 0, 2 );
702 lua_pushnumber( L, h );
703 return 1;
704}
705
719static int hookL_input( lua_State *L )
720{
721 unsigned int h = hookL_generic( L, "input", 0., 1, 0, 2 );
722 lua_pushnumber( L, h );
723 return 1;
724}
725
736static int hookL_mouse( lua_State *L )
737{
738 unsigned int h = hookL_generic( L, "mouse", 0., 1, 0, 2 );
739 lua_pushnumber( L, h );
740 return 1;
741}
742
755static int hookL_standing( lua_State *L )
756{
757 unsigned int h = hookL_generic( L, "standing", 0., 1, 0, 2 );
758 lua_pushnumber( L, h );
759 return 1;
760}
761
776static int hookL_discover( lua_State *L )
777{
778 unsigned int h = hookL_generic( L, "discover", 0., 1, 0, 2 );
779 lua_pushnumber( L, h );
780 return 1;
781}
782
793static int hookL_asteroidScan( lua_State *L )
794{
795 unsigned int h = hookL_generic( L, "asteroid_scan", 0., 1, 0, 2 );
796 lua_pushnumber( L, h );
797 return 1;
798}
799
811static int hookL_pay( lua_State *L )
812{
813 unsigned int h = hookL_generic( L, "pay", 0., 1, 0, 2 );
814 lua_pushnumber( L, h );
815 return 1;
816}
817
828static int hookL_safe( lua_State *L )
829{
830 unsigned int h = hookL_generic( L, "safe", 0., 1, 0, 2 );
831 lua_pushnumber( L, h );
832 return 1;
833}
834
848static int hookL_update( lua_State *L )
849{
850 unsigned int h = hookL_generic( L, "update", 0., 1, 0, 2 );
851 lua_pushnumber( L, h );
852 return 1;
853}
854
863static int hookL_renderbg( lua_State *L )
864{
865 unsigned int h = hookL_generic( L, "renderbg", 0., 1, 0, 2 );
866 lua_pushnumber( L, h );
867 return 1;
868}
869
878static int hookL_renderfg( lua_State *L )
879{
880 unsigned int h = hookL_generic( L, "renderfg", 0., 1, 0, 2 );
881 lua_pushnumber( L, h );
882 return 1;
883}
884
893static int hookL_rendertop( lua_State *L )
894{
895 unsigned int h = hookL_generic( L, "rendertop", 0., 1, 0, 2 );
896 lua_pushnumber( L, h );
897 return 1;
898}
899
908static int hookL_mission_done( lua_State *L )
909{
910 unsigned int h = hookL_generic( L, "mission_done", 0., 1, 0, 2 );
911 lua_pushnumber( L, h );
912 return 1;
913}
914
924static int hookL_custom( lua_State *L )
925{
926 const char *hookname = luaL_checkstring(L,1);
927 unsigned int h = hookL_generic( L, hookname, 0., 2, 0, 3 );
928 lua_pushnumber( L, h );
929 return 1;
930}
931
1000static int hookL_pilot( lua_State *L )
1001{
1002 unsigned int h;
1003 LuaPilot p;
1004 int type;
1005 const char *hook_type;
1006 char buf[64]; /* Large enough buffer to hold any of the allowed hook-type names. */
1007
1008 /* Parameters. */
1009 if (lua_ispilot(L,1))
1010 p = luaL_checkpilot(L,1);
1011 else if (lua_isnil(L,1))
1012 p = 0;
1013 else {
1014 NLUA_ERROR(L, _("Invalid parameter #1 for hook.pilot, expecting pilot or nil."));
1015 return 0;
1016 }
1017 hook_type = luaL_checkstring(L,2);
1018
1019 /* Check to see if hook_type is valid */
1020 if (strcmp(hook_type,"creation")==0) type = PILOT_HOOK_CREATION;
1021 else if (strcmp(hook_type,"death")==0) type = PILOT_HOOK_DEATH;
1022 else if (strcmp(hook_type,"exploded")==0) type = PILOT_HOOK_EXPLODED;
1023 else if (strcmp(hook_type,"boarding")==0) type = PILOT_HOOK_BOARDING;
1024 else if (strcmp(hook_type,"boardall")==0) type = PILOT_HOOK_BOARD_ALL;
1025 else if (strcmp(hook_type,"board")==0) type = PILOT_HOOK_BOARD;
1026 else if (strcmp(hook_type,"disable")==0) type = PILOT_HOOK_DISABLE;
1027 else if (strcmp(hook_type,"undisable")==0)type = PILOT_HOOK_UNDISABLE;
1028 else if (strcmp(hook_type,"jump")==0) type = PILOT_HOOK_JUMP;
1029 else if (strcmp(hook_type,"hail")==0) type = PILOT_HOOK_HAIL;
1030 else if (strcmp(hook_type,"land")==0) type = PILOT_HOOK_LAND;
1031 else if (strcmp(hook_type,"attacked")==0) type = PILOT_HOOK_ATTACKED;
1032 else if (strcmp(hook_type,"discovered")==0)type = PILOT_HOOK_DISCOVERED;
1033 else if (strcmp(hook_type,"scan")==0) type = PILOT_HOOK_SCAN;
1034 else if (strcmp(hook_type,"scanned")==0) type = PILOT_HOOK_SCANNED;
1035 else if (strcmp(hook_type,"idle")==0) type = PILOT_HOOK_IDLE;
1036 else if (strcmp(hook_type,"lockon")==0) type = PILOT_HOOK_LOCKON;
1037 else if (strcmp(hook_type,"stealth")==0) type = PILOT_HOOK_STEALTH;
1038 else { /* hook_type not valid */
1039 NLUA_ERROR(L, _("Invalid pilot hook type: '%s'"), hook_type);
1040 return 0;
1041 }
1042
1043#ifdef DEBUGGING
1044 if ((type == PILOT_HOOK_CREATION) && (p!=0))
1045 NLUA_ERROR( L, _("'creation' pilot hook can not be set on a specific pilot, only globally.") );
1046#endif /* DEBUGGING */
1047
1048 /* actually add the hook */
1049 snprintf( buf, sizeof(buf), "p_%s", hook_type );
1050 h = hookL_generic( L, buf, 0., 3, 0, 4 );
1051 if (p==0)
1052 pilots_addGlobalHook( type, h );
1053 else
1054 pilot_addHook( pilot_get(p), type, h );
1055
1056 lua_pushnumber( L, h );
1057 return 1;
1058}
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:563
nlua_env hook_env(unsigned int hook)
Gets the lua env for a hook.
Definition: hook.c:1007
unsigned int hook_addEvent(unsigned int parent, const char *func, const char *stack)
Adds a new event type hook.
Definition: hook.c:519
void hook_rm(unsigned int id)
Removes a hook.
Definition: hook.c:786
unsigned int hook_addTimerMisn(unsigned int parent, const char *func, double ms)
Adds a new mission type hook timer hook.
Definition: hook.c:539
unsigned int hook_addMisn(unsigned int parent, const char *func, const char *stack)
Adds a new mission type hook.
Definition: hook.c:499
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:530
static int hookL_rm(lua_State *L)
Lua bindings to manipulate hooks.
Definition: nlua_hook.c:156
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:776
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:924
static int hookL_hail(lua_State *L)
Hooks the function to the player hailing any ship (not a spob).
Definition: nlua_hook.c:474
void hookL_unsetarg(unsigned int hook)
Unsets a Lua argument.
Definition: nlua_hook.c:197
static int hookL_gather(lua_State *L)
Hooks the function to the player gatehring any sort of commodity in space.
Definition: nlua_hook.c:599
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:878
static int hookL_shipbuy(lua_State *L)
Hooks the function to the player buying any sort of ship.
Definition: nlua_hook.c:665
static int hookL_timer(lua_State *L)
Hooks a timer.
Definition: nlua_hook.c:509
static int hookL_pilot(lua_State *L)
Hooks the function to a specific pilot.
Definition: nlua_hook.c:1000
static int hookL_outfitbuy(lua_State *L)
Hooks the function to the player buying any sort of outfit.
Definition: nlua_hook.c:616
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:251
static int hookL_input(lua_State *L)
Hooks the function to the player pressing any input.
Definition: nlua_hook.c:719
int nlua_loadHook(nlua_env env)
Loads the hook Lua library.
Definition: nlua_hook.c:121
static int hookL_asteroidScan(lua_State *L)
Hooks the function to when the player scans an asteroid.
Definition: nlua_hook.c:793
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:491
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:893
static int hookL_setarg(unsigned int hook, int ind)
Sets a Lua argument for a hook.
Definition: nlua_hook.c:174
static int hookL_equip(lua_State *L)
Hooks the function to the player equipping or deequipping any outfit.
Definition: nlua_hook.c:648
static int hookL_commsell(lua_State *L)
Hooks the function to the player selling any sort of commodity.
Definition: nlua_hook.c:565
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:828
static int hookL_shipsell(lua_State *L)
Hooks the function to the player selling any sort of ship.
Definition: nlua_hook.c:682
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:755
static const luaL_Reg hookL_methods[]
Definition: nlua_hook.c:70
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:582
static int hookL_commbuy(lua_State *L)
Hooks the function to the player buying any sort of commodity.
Definition: nlua_hook.c:548
static int hookL_outfitsell(lua_State *L)
Hooks the function to the player selling any sort of outfit.
Definition: nlua_hook.c:633
static int hookL_shipswap(lua_State *L)
Hooks the function to the player swapping their ship.
Definition: nlua_hook.c:699
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:811
static int hookL_renderbg(lua_State *L)
Hook that runs during rendering the background (just above the static background stuff)....
Definition: nlua_hook.c:863
int hookL_getarg(unsigned int hook)
Gets a Lua argument for a hook.
Definition: nlua_hook.c:220
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:908
static int hookL_mouse(lua_State *L)
Hooks the function to the player clicking the mouse.
Definition: nlua_hook.c:736
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:848
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:510
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:464
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:589
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:79
unsigned int id
Definition: mission.h:81