MCPcopy Create free account
hub / github.com/DFHack/dfhack / dfhack_random_unitvector

Function dfhack_random_unitvector

library/LuaApi.cpp:1177–1191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1175 return 1;
1176}
1177static int dfhack_random_unitvector(lua_State *L)
1178{
1179 MersenneRNG *prng = check_random_native(L, 1);
1180 int size = luaL_optint(L, 2, 3);
1181 if (size <= 0 || size > 32)
1182 luaL_argerror(L, 2, "vector size must be positive");
1183 luaL_checkstack(L, size, "not enough stack in dfhack.random.unitvector");
1184
1185 vector<double> buf(size);
1186 prng->unitvector(buf.data(), size);
1187
1188 for (int i = 0; i < size; i++)
1189 lua_pushnumber(L, buf[i]);
1190 return size;
1191}
1192
1193static int eval_perlin_1(lua_State *L)
1194{

Callers

nothing calls this directly

Calls 6

check_random_nativeFunction · 0.85
luaL_argerrorFunction · 0.85
luaL_checkstackFunction · 0.85
lua_pushnumberFunction · 0.85
unitvectorMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected