From b0aeb6ce034bc3ae10681130572207bde42e7d13 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Thu, 27 May 2021 18:35:15 -0400 Subject: [PATCH] Expose M_MapNumber to Lua --- src/lua_baselib.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 53127a72f..d2609049f 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -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},