diff options
author | kwolekr <kwolekr@minetest.net> | 2014-02-15 18:20:15 -0500 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2014-02-15 19:13:14 -0500 |
commit | 3570f3e396acad4a6b5381d06c2dae5cf4e95fbd (patch) | |
tree | 1ce53a41271802efdd9f88de83b2c68e06cd2f33 /src/script/lua_api/l_mapgen.cpp | |
parent | c87316487840fd176662207acef4fb15286e32e8 (diff) | |
download | minetest-3570f3e396acad4a6b5381d06c2dae5cf4e95fbd.tar.gz minetest-3570f3e396acad4a6b5381d06c2dae5cf4e95fbd.tar.bz2 minetest-3570f3e396acad4a6b5381d06c2dae5cf4e95fbd.zip |
Add minetest.set_noiseparam_defaults() Lua API
Diffstat (limited to 'src/script/lua_api/l_mapgen.cpp')
-rw-r--r-- | src/script/lua_api/l_mapgen.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index 2e6d848b3..a7af856de 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -229,6 +229,33 @@ int ModApiMapgen::l_set_mapgen_params(lua_State *L) return 0; } +// minetest.set_noiseparam_defaults({np1={noise params}, ...}) +// set default values for noise parameters if not present in global settings +int ModApiMapgen::l_set_noiseparam_defaults(lua_State *L) +{ + NoiseParams np; + std::string val, name; + + if (!lua_istable(L, 1)) + return 0; + + lua_pushnil(L); + while (lua_next(L, 1)) { + if (read_noiseparams_nc(L, -1, &np)) { + if (!serializeStructToString(&val, NOISEPARAMS_FMT_STR, &np)) + continue; + if (!lua_isstring(L, -2)) + continue; + + name = lua_tostring(L, -2); + g_settings->setDefault(name, val); + } + lua_pop(L, 1); + } + + return 0; +} + // set_gen_notify(string) int ModApiMapgen::l_set_gen_notify(lua_State *L) { @@ -607,6 +634,7 @@ void ModApiMapgen::Initialize(lua_State *L, int top) API_FCT(get_mapgen_object); API_FCT(set_mapgen_params); + API_FCT(set_noiseparam_defaults); API_FCT(set_gen_notify); API_FCT(register_biome); |