Merge branch 'lua_mapnumber' into 'next'

Expose M_MapNumber to Lua

See merge request STJr/SRB2!1521
This commit is contained in:
Nev3r 2021-06-01 07:43:33 -04:00
commit f7ee0dacf2

View file

@ -28,6 +28,7 @@
#include "console.h"
#include "d_netcmd.h" // IsPlayerAdmin
#include "m_menu.h" // Player Setup menu color stuff
#include "m_misc.h" // M_MapNumber
#include "lua_script.h"
#include "lua_libs.h"
@ -357,6 +358,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
//////////////
@ -3724,6 +3742,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},