mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-14 09:05:19 +02:00
Improvements/fixes for noise parameter input in advanced settings
Formspec input for each individual noise parameter and flag. Allow noise flags to be set in advanced settings, previously only settable in minetest.conf. Standardise 'group format' for noise parameters set in minetest.conf, as only these support noise flags. However the older 'single line' format is still accepted to support existing minetest.conf files. Therefore auto-generate minetest.conf.example with noise parameters in 'group format'. Setting 'type' in settingtypes.txt is now either 'noise_params_2D' or 'noise_params_3D', the dimension number is displayed in the advanced settings edit page.
This commit is contained in:
committed by
paramat
parent
c60abb2aec
commit
a1e1a19ac3
@@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "lua_api/l_internal.h"
|
||||
#include "cpp_api/s_security.h"
|
||||
#include "settings.h"
|
||||
#include "noise.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
@@ -105,6 +106,24 @@ int LuaSettings::l_get_bool(lua_State* L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// get_np_group(self, key) -> value
|
||||
int LuaSettings::l_get_np_group(lua_State *L)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
LuaSettings *o = checkobject(L, 1);
|
||||
|
||||
std::string key = std::string(luaL_checkstring(L, 2));
|
||||
if (o->m_settings->exists(key)) {
|
||||
NoiseParams np;
|
||||
o->m_settings->getNoiseParams(key, np);
|
||||
push_noiseparams(L, &np);
|
||||
} else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// set(self, key, value)
|
||||
int LuaSettings::l_set(lua_State* L)
|
||||
{
|
||||
@@ -138,6 +157,23 @@ int LuaSettings::l_set_bool(lua_State* L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// set(self, key, value)
|
||||
int LuaSettings::l_set_np_group(lua_State *L)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
LuaSettings *o = checkobject(L, 1);
|
||||
|
||||
std::string key = std::string(luaL_checkstring(L, 2));
|
||||
NoiseParams value;
|
||||
read_noiseparams(L, 3, &value);
|
||||
|
||||
SET_SECURITY_CHECK(L, key);
|
||||
|
||||
o->m_settings->setNoiseParams(key, value, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// remove(self, key) -> success
|
||||
int LuaSettings::l_remove(lua_State* L)
|
||||
{
|
||||
@@ -264,8 +300,10 @@ const char LuaSettings::className[] = "Settings";
|
||||
const luaL_Reg LuaSettings::methods[] = {
|
||||
luamethod(LuaSettings, get),
|
||||
luamethod(LuaSettings, get_bool),
|
||||
luamethod(LuaSettings, get_np_group),
|
||||
luamethod(LuaSettings, set),
|
||||
luamethod(LuaSettings, set_bool),
|
||||
luamethod(LuaSettings, set_np_group),
|
||||
luamethod(LuaSettings, remove),
|
||||
luamethod(LuaSettings, get_names),
|
||||
luamethod(LuaSettings, write),
|
||||
|
Reference in New Issue
Block a user