Check in code for new random number generator

This commit is contained in:
2022-03-31 17:15:15 -04:00
parent 7fc6263e37
commit c48e02642a
9 changed files with 291 additions and 8 deletions

View File

@@ -351,6 +351,7 @@ eng::string SourceDB::rebuild() {
LS.makeclass(mathclass, "math");
LS.rawset(mathclass, "pi", M_PI);
LS.rawset(mathclass, "huge", HUGE_VAL);
LS.rawset(mathclass, "maxint", LuaStack::MAXINT);
LS.result();
return errs;
@@ -734,14 +735,15 @@ LuaDefineBuiltin(math_min, "x, x, x...", "return the smallest argument");
LuaDefineBuiltin(math_modf, "x", "returns the integral and fractional part of x");
LuaDefineBuiltin(math_pow, "x, y", "returns x ^ y, equivalent to the operator");
LuaDefineBuiltin(math_rad, "deg", "convert degrees to radians");
LuaDefineBuiltin(math_random, "[m [, n]]", "return random [0.0-1.0), or [1-m], or [m-n].");
LuaDefineBuiltin(math_randomseed, "x", "set x as the seed for random numbers");
LuaDefineBuiltin(math_sin, "x", "return the sine of x in radians");
LuaDefineBuiltin(math_sinh, "x", "return the hyperbolic sine of x in radians");
LuaDefineBuiltin(math_sqrt, "x", "return the square root of x");
LuaDefineBuiltin(math_tan, "x", "return the tangent of x in radians");
LuaDefineBuiltin(math_tanh, "x", "return the hyperbolic tangent of x in radians");
LuaSandboxBuiltin(math_log10, "", "");
// math.random and math.randomseed are in world-accessor.cpp, because
// generating random numbers must manipulate global state which is
// stored in the world model.
LuaDefineBuiltin(assert, "flag [,message]", "assert that flag is true, if not, raise error");
LuaDefineBuiltin(error, "message", "raise an error");