17 lines
792 B
C++
17 lines
792 B
C++
#include "classes.h"
|
|
#include "lua/api.h"
|
|
#include "engine/seeds.h"
|
|
|
|
// (008bbcf0) Registers Lua's RNG: a default seeded constructor and the game's RNG methods.
|
|
void lua_api_rng_register(lua_State* state)
|
|
{
|
|
lua_class_begin(state, "RNG", LUA_CLASS_RNG);
|
|
lua_static(state, "__call", [](LuaIgnored) { return RNG_DEFAULT; });
|
|
lua_method(state, "GetSeed", [](RNG& rng) { return rng._seed; });
|
|
lua_method(state, "SetSeed", [](RNG& rng, uint32_t seed, uint32_t shiftIndex) { rng.SetSeed(seed, shiftIndex); });
|
|
lua_method(state, "RandomInt", [](RNG& rng, uint32_t max) { return rng.RandomInt(max); });
|
|
lua_method(state, "RandomFloat", [](RNG& rng) { return rng.RandomFloat(); });
|
|
lua_method(state, "Next", [](RNG& rng) { return rng.Next(); });
|
|
lua_class_end(state);
|
|
}
|