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

Function dfhack_random_perlin

library/LuaApi.cpp:1212–1242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1210}
1211
1212static int dfhack_random_perlin(lua_State *L)
1213{
1214 MersenneRNG *prng = check_random_native(L, 1);
1215 int size = luaL_optint(L, 2, 3);
1216
1217 switch (size)
1218 {
1219 case 1: {
1220 auto pdata = Lua::make_lua_userdata<PerlinNoise1D<float>>(L);
1221 pdata->init(*prng);
1222 lua_pushcclosure(L, eval_perlin_1, 1);
1223 break;
1224 }
1225 case 2: {
1226 auto pdata = Lua::make_lua_userdata<PerlinNoise2D<float>>(L);
1227 pdata->init(*prng);
1228 lua_pushcclosure(L, eval_perlin_2, 1);
1229 break;
1230 }
1231 case 3: {
1232 auto pdata = Lua::make_lua_userdata<PerlinNoise3D<float>>(L);
1233 pdata->init(*prng);
1234 lua_pushcclosure(L, eval_perlin_3, 1);
1235 break;
1236 }
1237 default:
1238 luaL_argerror(L, 2, "perlin noise dimension must be 1, 2 or 3");
1239 }
1240
1241 return 1;
1242}
1243
1244static const luaL_Reg dfhack_random_funcs[] = {
1245 { "new", dfhack_random_new },

Callers

nothing calls this directly

Calls 4

check_random_nativeFunction · 0.85
lua_pushcclosureFunction · 0.85
luaL_argerrorFunction · 0.85
initMethod · 0.45

Tested by

no test coverage detected