mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-02 06:23:03 +00:00
Expose G_BuildMapTitle to Lua
This commit is contained in:
parent
7d5a8ac14b
commit
50b18acd3f
1 changed files with 23 additions and 4 deletions
|
@ -2772,7 +2772,7 @@ static int lib_gAddGametype(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int Lcheckmapnumber (lua_State *L, int idx)
|
||||
static int Lcheckmapnumber (lua_State *L, int idx, const char *fun)
|
||||
{
|
||||
if (ISINLEVEL)
|
||||
return luaL_optinteger(L, idx, gamemap);
|
||||
|
@ -2781,8 +2781,8 @@ static int Lcheckmapnumber (lua_State *L, int idx)
|
|||
if (lua_isnoneornil(L, idx))
|
||||
{
|
||||
return luaL_error(L,
|
||||
"G_BuildMapName can only be used "
|
||||
"without a parameter while in a level."
|
||||
"%s can only be used without a parameter while in a level.",
|
||||
fun
|
||||
);
|
||||
}
|
||||
else
|
||||
|
@ -2792,12 +2792,30 @@ static int Lcheckmapnumber (lua_State *L, int idx)
|
|||
|
||||
static int lib_gBuildMapName(lua_State *L)
|
||||
{
|
||||
INT32 map = Lcheckmapnumber(L, 1);
|
||||
INT32 map = Lcheckmapnumber(L, 1, "G_BuildMapName");
|
||||
//HUDSAFE
|
||||
lua_pushstring(L, G_BuildMapName(map));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_gBuildMapTitle(lua_State *L)
|
||||
{
|
||||
INT32 map = Lcheckmapnumber(L, 1, "G_BuoldMapTitle");
|
||||
char *name;
|
||||
if (map < 1 || map > NUMMAPS)
|
||||
{
|
||||
return luaL_error(L,
|
||||
"map number %d out of range (1 - %d)",
|
||||
map,
|
||||
NUMMAPS
|
||||
);
|
||||
}
|
||||
name = G_BuildMapTitle(map);
|
||||
lua_pushstring(L, name);
|
||||
Z_Free(name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_gDoReborn(lua_State *L)
|
||||
{
|
||||
INT32 playernum = luaL_checkinteger(L, 1);
|
||||
|
@ -3174,6 +3192,7 @@ static luaL_Reg lib[] = {
|
|||
// g_game
|
||||
{"G_AddGametype", lib_gAddGametype},
|
||||
{"G_BuildMapName",lib_gBuildMapName},
|
||||
{"G_BuildMapTitle",lib_gBuildMapTitle},
|
||||
{"G_DoReborn",lib_gDoReborn},
|
||||
{"G_SetCustomExitVars",lib_gSetCustomExitVars},
|
||||
{"G_EnoughPlayersFinished",lib_gEnoughPlayersFinished},
|
||||
|
|
Loading…
Reference in a new issue