30 if (lua_isnoneornil(L, 1)) {
32 double r_max =
static_cast<double>(std::numeric_limits<uint32_t>::max());
39 if (lua_isnumber(L, 2)) {
40 min = lua_check<int32_t>(L, 1);
41 max = lua_check<int32_t>(L, 2);
45 max = lua_check<int32_t>(L, 1);
48 return luaL_argerror(L, 1,
"min > max");
56 double n = lua_tonumber(L, 1);
57 lua_pushinteger(L, std::round(
n));
62 auto& lk = lua_kernel_base::get_lua_kernel<lua_kernel_base>(L);
63 lk.add_log(
"Adding mathx module...\n");
64 static luaL_Reg
const math_callbacks[] = {
70 luaL_setfuncs(L, math_callbacks, 0);
72 lua_createtable(L, 0, 1);
73 lua_getglobal(L,
"math");
74 lua_setfield(L, -2,
"__index");
75 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