20 #include "SDL2/SDL_timer.h"
34 if (lua_isnoneornil(L, 1)) {
36 double r_max =
static_cast<double>(std::numeric_limits<uint32_t>::max());
43 if (lua_isnumber(L, 2)) {
44 min = lua_check<int32_t>(L, 1);
45 max = lua_check<int32_t>(L, 2);
49 max = lua_check<int32_t>(L, 1);
52 return luaL_argerror(L, 1,
"min > max");
60 double n = lua_tonumber(L, 1);
61 lua_pushinteger(L, std::round(
n));
66 auto& lk = lua_kernel_base::get_lua_kernel<lua_kernel_base>(L);
67 lk.add_log(
"Adding mathx module...\n");
68 static luaL_Reg
const math_callbacks[] = {
74 luaL_setfuncs(L, math_callbacks, 0);
76 lua_createtable(L, 0, 1);
77 lua_getglobal(L,
"math");
78 lua_setfield(L, -2,
"__index");
79 lua_setmetatable(L, -2);
uint32_t next_random()
Provides the next random draw.
static int intf_round(lua_State *L)
static int intf_random(lua_State *L)
Returns a random number, same interface as math.random.
int luaW_open(lua_State *L)
rng * generator
This generator is automatically synced during synced context.
void lua_push(lua_State *L, const T &val)
static map_location::DIRECTION n