From ceb96b0f13ebe07c1df5c5ae7c8be9e54bb15521 Mon Sep 17 00:00:00 2001 From: Allanis <allanis@saracraft.net> Date: Mon, 22 Apr 2013 16:13:58 +0100 Subject: [PATCH] [Add] More hooks to mission lua and improved behaviour. --- src/misn_lua.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/misn_lua.c b/src/misn_lua.c index 20e33e7..6aabc87 100644 --- a/src/misn_lua.c +++ b/src/misn_lua.c @@ -48,6 +48,7 @@ static Mission* cur_mission = NULL; static int misn_delete = 0; // If 1 delete current mission. static void var_free(misn_var* var); +static int hook_generic(lua_State* L, char* stack); // -- Libraries. -- @@ -139,9 +140,14 @@ static const luaL_Reg tk_methods[] = { { 0, 0 } }; +// Hooks. static int hook_land(lua_State* L); +static int hook_takeoff(lua_State* L); +static int hook_time(lua_State* L); static const luaL_Reg hook_methods[] = { - { "land", hook_land }, + { "land", hook_land }, + { "takeoff", hook_takeoff }, + { "time", hook_time }, { 0, 0 } }; @@ -667,7 +673,7 @@ static int tk_input(lua_State* L) { } // -- HOOK -- -static int hook_land(lua_State* L) { +static int hook_generic(lua_State* L, char* stack) { int i; char* func; @@ -687,7 +693,22 @@ static int hook_land(lua_State* L) { cur_mission->data->name); return 0; } - hook_add(cur_mission->id, func, "land"); + hook_add(cur_mission->id, func, stack); + return 0; +} + +static int hook_land(lua_State* L) { + hook_generic(L, "land"); + return 0; +} + +static int hook_takeoff(lua_State* L) { + hook_generic(L, "takeoff"); + return 0; +} + +static int hook_time(lua_State* L) { + hook_generic(L, "time"); return 0; }