mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-12 23:16:03 +00:00
Allow G_BuildMapName outside of levels
This commit is contained in:
parent
acb3372644
commit
7d5a8ac14b
2 changed files with 23 additions and 3 deletions
|
@ -2772,11 +2772,28 @@ static int lib_gAddGametype(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int Lcheckmapnumber (lua_State *L, int idx)
|
||||||
|
{
|
||||||
|
if (ISINLEVEL)
|
||||||
|
return luaL_optinteger(L, idx, gamemap);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (lua_isnoneornil(L, idx))
|
||||||
|
{
|
||||||
|
return luaL_error(L,
|
||||||
|
"G_BuildMapName can only be used "
|
||||||
|
"without a parameter while in a level."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return luaL_checkinteger(L, idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int lib_gBuildMapName(lua_State *L)
|
static int lib_gBuildMapName(lua_State *L)
|
||||||
{
|
{
|
||||||
INT32 map = luaL_optinteger(L, 1, gamemap);
|
INT32 map = Lcheckmapnumber(L, 1);
|
||||||
//HUDSAFE
|
//HUDSAFE
|
||||||
INLEVEL
|
|
||||||
lua_pushstring(L, G_BuildMapName(map));
|
lua_pushstring(L, G_BuildMapName(map));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,10 @@ void COM_Lua_f(void);
|
||||||
// uncomment if you want seg_t/node_t in Lua
|
// uncomment if you want seg_t/node_t in Lua
|
||||||
// #define HAVE_LUA_SEGS
|
// #define HAVE_LUA_SEGS
|
||||||
|
|
||||||
#define INLEVEL if (gamestate != GS_LEVEL && !titlemapinaction)\
|
#define ISINLEVEL \
|
||||||
|
(gamestate == GS_LEVEL || titlemapinaction)
|
||||||
|
|
||||||
|
#define INLEVEL if (! ISINLEVEL)\
|
||||||
return luaL_error(L, "This can only be used in a level!");
|
return luaL_error(L, "This can only be used in a level!");
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue