Merge branch 'lua-nextmapoverride' into 'next'

Lua: nextmapoverride & skipstats changing outside of G_ExitLevel

See merge request STJr/SRB2!396
This commit is contained in:
Digiku 2018-12-20 10:55:30 -05:00
commit dd107724de
1 changed files with 23 additions and 5 deletions

View File

@ -1916,17 +1916,19 @@ static int lib_gDoReborn(lua_State *L)
return 0;
}
static int lib_gExitLevel(lua_State *L)
// Another Lua function that doesn't actually exist!
// Sets nextmapoverride & skipstats without instantly ending the level, for instances where other sources should be exiting the level, like normal signposts.
static int lib_gSetCustomExitVars(lua_State *L)
{
int n = lua_gettop(L); // Num arguments
NOHUD
// LUA EXTENSION: Custom exit like support
// Supported:
// G_ExitLevel(); [no modifications]
// G_ExitLevel(int) [nextmap override only]
// G_ExitLevel(bool) [skipstats only]
// G_ExitLevel(int, bool) [both of the above]
// G_SetCustomExitVars(); [reset to defaults]
// G_SetCustomExitVars(int) [nextmap override only]
// G_SetCustomExitVars(bool) [skipstats only]
// G_SetCustomExitVars(int, bool) [both of the above]
if (n >= 1)
{
if (lua_isnumber(L, 1) || n >= 2)
@ -1936,8 +1938,23 @@ static int lib_gExitLevel(lua_State *L)
}
skipstats = lua_optboolean(L, 1);
}
else
{
nextmapoverride = 0;
skipstats = false;
}
// ---
return 0;
}
static int lib_gExitLevel(lua_State *L)
{
int n = lua_gettop(L); // Num arguments
NOHUD
// Moved this bit to G_SetCustomExitVars
if (n >= 1) // Don't run the reset to defaults option
lib_gSetCustomExitVars(L);
G_ExitLevel();
return 0;
}
@ -2202,6 +2219,7 @@ static luaL_Reg lib[] = {
// g_game
{"G_BuildMapName",lib_gBuildMapName},
{"G_DoReborn",lib_gDoReborn},
{"G_SetCustomExitVars",lib_gSetCustomExitVars},
{"G_ExitLevel",lib_gExitLevel},
{"G_IsSpecialStage",lib_gIsSpecialStage},
{"G_GametypeUsesLives",lib_gGametypeUsesLives},