Expose M_MapNumber to Lua

This commit is contained in:
flarn2006 2021-05-27 18:35:15 -04:00 committed by toaster
parent 2cfdf80fca
commit b0aeb6ce03

View file

@ -34,6 +34,7 @@
#include "k_hud.h"
#include "d_netcmd.h" // IsPlayerAdmin
#include "m_menu.h" // Player Setup menu color stuff
#include "m_misc.h" // M_MapNumber
// SRB2Kart
#include "p_spec.h" // P_StartQuake
@ -365,6 +366,23 @@ static int lib_pGetColorAfter(lua_State *L)
return 1;
}
// M_MISC
//////////////
static int lib_mMapNumber(lua_State *L)
{
const char *arg = luaL_checkstring(L, 1);
size_t len = strlen(arg);
if (len == 2 || len == 5) {
char first = arg[len-2];
char second = arg[len-1];
lua_pushinteger(L, M_MapNumber(first, second));
} else {
lua_pushinteger(L, 0);
}
return 1;
}
// M_RANDOM
//////////////
@ -3830,6 +3848,9 @@ static luaL_Reg lib[] = {
{"M_GetColorAfter",lib_pGetColorAfter},
{"M_GetColorBefore",lib_pGetColorBefore},
// m_misc
{"M_MapNumber",lib_mMapNumber},
// m_random
{"P_RandomFixed",lib_pRandomFixed},
{"P_RandomByte",lib_pRandomByte},