| 629 | |
| 630 | |
| 631 | static int math_randomseed (lua_State *L) { |
| 632 | RanState *state = (RanState *)lua_touserdata(L, lua_upvalueindex(1)); |
| 633 | lua_Unsigned n1, n2; |
| 634 | if (lua_isnone(L, 1)) { |
| 635 | n1 = luaL_makeseed(L); /* "random" seed */ |
| 636 | n2 = I2UInt(nextrand(state->s)); /* in case seed is not that random... */ |
| 637 | } |
| 638 | else { |
| 639 | n1 = l_castS2U(luaL_checkinteger(L, 1)); |
| 640 | n2 = l_castS2U(luaL_optinteger(L, 2, 0)); |
| 641 | } |
| 642 | setseed(L, state->s, n1, n2); |
| 643 | return 2; /* return seeds */ |
| 644 | } |
| 645 | |
| 646 | |
| 647 | static const luaL_Reg randfuncs[] = { |
nothing calls this directly
no test coverage detected