[Add] More hooks to mission lua and improved behaviour.

This commit is contained in:
Allanis 2013-04-22 16:13:58 +01:00
parent 3a4115ca5d
commit ceb96b0f13

View File

@ -48,6 +48,7 @@ static Mission* cur_mission = NULL;
static int misn_delete = 0; // If 1 delete current mission. static int misn_delete = 0; // If 1 delete current mission.
static void var_free(misn_var* var); static void var_free(misn_var* var);
static int hook_generic(lua_State* L, char* stack);
// -- Libraries. -- // -- Libraries. --
@ -139,9 +140,14 @@ static const luaL_Reg tk_methods[] = {
{ 0, 0 } { 0, 0 }
}; };
// Hooks.
static int hook_land(lua_State* L); 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[] = { static const luaL_Reg hook_methods[] = {
{ "land", hook_land }, { "land", hook_land },
{ "takeoff", hook_takeoff },
{ "time", hook_time },
{ 0, 0 } { 0, 0 }
}; };
@ -667,7 +673,7 @@ static int tk_input(lua_State* L) {
} }
// -- HOOK -- // -- HOOK --
static int hook_land(lua_State* L) { static int hook_generic(lua_State* L, char* stack) {
int i; int i;
char* func; char* func;
@ -687,7 +693,22 @@ static int hook_land(lua_State* L) {
cur_mission->data->name); cur_mission->data->name);
return 0; 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; return 0;
} }