From 1bec93918e507b2f05be5abeb4be1e2eaa31bde4 Mon Sep 17 00:00:00 2001 From: Allanis Date: Mon, 6 May 2013 23:18:36 +0100 Subject: [PATCH] [Add] Few additions to lua mission wrappers ready for a new type of mission. --- dat/mission.xml | 2 +- dat/missions/cargo.lua | 2 +- .../{empire00.lua => emp_cargo00.lua} | 0 dat/missions/es_cargo.lua | 2 +- src/land.c | 1 + src/misn_lua.c | 37 +++++++++++++++++-- src/player.c | 1 + 7 files changed, 38 insertions(+), 7 deletions(-) rename dat/missions/{empire00.lua => emp_cargo00.lua} (100%) diff --git a/dat/mission.xml b/dat/mission.xml index 70bd256..c9dd241 100644 --- a/dat/mission.xml +++ b/dat/mission.xml @@ -18,7 +18,7 @@ - empire00 + emp_empire00 1 diff --git a/dat/missions/cargo.lua b/dat/missions/cargo.lua index 31e7e20..e9b3c05 100644 --- a/dat/missions/cargo.lua +++ b/dat/missions/cargo.lua @@ -22,7 +22,7 @@ else -- Default English. finish_msg = "The workers unload the %s at the docks." miss_title = "Cargo missing" miss_msg = "You are missing the %d tons of %s!" - misn_time_msg = "You have failed to deliver the goods on time!" + misn_time_msg = "MISSION FAILED: You have failed to deliver the goods on time!" end -- Create the mission. diff --git a/dat/missions/empire00.lua b/dat/missions/emp_cargo00.lua similarity index 100% rename from dat/missions/empire00.lua rename to dat/missions/emp_cargo00.lua diff --git a/dat/missions/es_cargo.lua b/dat/missions/es_cargo.lua index 836d7b9..f23935c 100644 --- a/dat/missions/es_cargo.lua +++ b/dat/missions/es_cargo.lua @@ -17,7 +17,7 @@ else -- Default English. finish_msg = "The Empire workers unload the %s at the docks." miss_title = "Cargo Missing" miss_msg = "You are missing the %d tons of %s!" - miss_timeup = "You have failed to deliver the goods to the empire on time!" + miss_timeup = "MISSION FAILED: You have failed to deliver the goods to the empire on time!" end -- Empire shipping missions are always timed, but quite lax on the schedules. diff --git a/src/land.c b/src/land.c index d94299c..d0c3fba 100644 --- a/src/land.c +++ b/src/land.c @@ -1011,6 +1011,7 @@ void takeoff(void) { landed = 0; land_visited = 0; hooks_run("takeoff"); + hooks_run("enter"); // Cleanup mission computer. for(i = 0; i < mission_ncomputer; i++) diff --git a/src/misn_lua.c b/src/misn_lua.c index af42aab..d870e47 100644 --- a/src/misn_lua.c +++ b/src/misn_lua.c @@ -91,12 +91,14 @@ static const luaL_reg var_methods[] = { static int space_getPlanet(lua_State* L); static int space_getSystem(lua_State* L); static int space_landName(lua_State* L); +static int space_systemName(lua_State* L); static int space_jumpDist(lua_State* L); static const luaL_reg space_methods[] = { - { "getPlanet", space_getPlanet }, - { "getSystem", space_getSystem }, - { "landName", space_landName }, - { "jumpDist", space_jumpDist }, + { "getPlanet", space_getPlanet }, + { "getSystem", space_getSystem }, + { "landName", space_landName }, + { "system", space_systemName }, + { "jumpDist", space_jumpDist }, { 0, 0 } }; @@ -112,12 +114,16 @@ static const luaL_reg time_methods[] = { }; // Player. +static int player_getname(lua_State* L); +static int player_shipname(lua_State* L); static int player_freeSpace(lua_State* L); static int player_addCargo(lua_State* L); static int player_rmCargo(lua_State* L); static int player_pay(lua_State* L); static int player_msg(lua_State* L); static const luaL_reg player_methods[] = { + { "name", player_getname }, + { "ship", player_shipname }, { "freeCargo", player_freeSpace }, { "addCargo", player_addCargo }, { "rmCargo", player_rmCargo }, @@ -148,11 +154,13 @@ static const luaL_reg tk_methods[] = { static int hook_land(lua_State* L); static int hook_takeoff(lua_State* L); static int hook_time(lua_State* L); +static int hook_enter(lua_State* L); static int hook_pilotDeath(lua_State* L); static const luaL_reg hook_methods[] = { { "land", hook_land }, { "takeoff", hook_takeoff }, { "time", hook_time }, + { "enter", hook_enter }, { "pilotDeath", hook_pilotDeath }, { 0, 0 } }; @@ -534,6 +542,11 @@ static int space_landName(lua_State* L) { return 0; } +static int space_systemName(lua_State* L) { + lua_pushstring(L, cur_system->name); + return 1; +} + static int space_jumpDist(lua_State* L) { MIN_ARGS(1); StarSystem** s; @@ -585,6 +598,17 @@ static int time_units(lua_State* L) { } // -- Player. -- + +static int player_getname(lua_State* L) { + lua_pushstring(L, player_name); + return 1; +} + +static int player_shipname(lua_State* L) { + lua_pushstring(L, player->name); + return 1; +} + static int player_freeSpace(lua_State* L) { lua_pushnumber(L, pilot_freeCargo(player)); return 1; @@ -762,6 +786,11 @@ static int hook_time(lua_State* L) { return 0; } +static int hook_enter(lua_State* L) { + hook_generic(L, "enter"); + return 0; +} + static int hook_pilotDeath(lua_State* L) { MIN_ARGS(2); int h; diff --git a/src/player.c b/src/player.c index 5676d68..cb64cca 100644 --- a/src/player.c +++ b/src/player.c @@ -1277,6 +1277,7 @@ void player_brokeHyperspace(void) { // Run the jump hooks. hooks_run("jump"); + hooks_run("enter"); player_message("BANG!"); }