Readded EvalMath to Lua.

There is a caveat to this: The first time EvalMath is used, a
deprecated function warning will be shown to the user that tells
them to use _G[] instead.

This reverts commit 9d36cf37bd.
This commit is contained in:
Inuyasha 2016-03-08 22:15:26 -08:00
parent 694220155e
commit cfcd7ce0d3
2 changed files with 20 additions and 0 deletions

View file

@ -85,6 +85,14 @@ static int lib_print(lua_State *L)
return 0;
}
static int lib_evalMath(lua_State *L)
{
const char *word = luaL_checkstring(L, 1);
LUA_Deprecated(L, "EvalMath(string)", "_G[string]");
lua_pushinteger(L, LUA_EvalMath(word));
return 1;
}
// M_RANDOM
//////////////
@ -1899,6 +1907,7 @@ static int lib_gTicsToMilliseconds(lua_State *L)
static luaL_Reg lib[] = {
{"print", lib_print},
{"EvalMath", lib_evalMath},
// m_random
{"P_Random",lib_pRandom},

View file

@ -70,4 +70,15 @@ void COM_Lua_f(void);
#define LUA_ErrInvalid(L, type) luaL_error(L, "accessed " type " doesn't exist anymore, please check 'valid' before using " type ".");
// Deprecation warnings
// Shows once upon use. Then doesn't show again.
#define LUA_Deprecated(L,this_func,use_instead)\
{\
static UINT8 seen = 0;\
if (!seen) {\
seen = 1;\
CONS_Alert(CONS_WARNING,"\"%s\" is deprecated and will be removed.\nUse \"%s\" instead.\n", this_func, use_instead);\
}\
}
#endif