summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAFCMS <afcm.contact@gmail.com>2022-08-02 11:58:08 +0200
committerGitHub <noreply@github.com>2022-08-02 11:58:08 +0200
commit6ec6acc539321709ed8517f1a571777a04f5c24c (patch)
tree7b63437670a07e218e4af5ebe942e0e3130ec629 /src
parent839600ed703ccffbdb71bd2f04fb379d0920da95 (diff)
downloadminetest-6ec6acc539321709ed8517f1a571777a04f5c24c.tar.gz
minetest-6ec6acc539321709ed8517f1a571777a04f5c24c.tar.bz2
minetest-6ec6acc539321709ed8517f1a571777a04f5c24c.zip
Add `minetest.settings` to CSM API and allow CSMs to provide `settingtypes.txt` (#12131)
Co-authored-by: sfan5 <sfan5@live.de> Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/script/cpp_api/s_security.cpp6
-rw-r--r--src/script/lua_api/l_util.cpp3
-rw-r--r--src/script/scripting_client.cpp2
3 files changed, 11 insertions, 0 deletions
diff --git a/src/script/cpp_api/s_security.cpp b/src/script/cpp_api/s_security.cpp
index 88e22f16f..316b19926 100644
--- a/src/script/cpp_api/s_security.cpp
+++ b/src/script/cpp_api/s_security.cpp
@@ -417,6 +417,12 @@ void ScriptApiSecurity::setLuaEnv(lua_State *L, int thread)
bool ScriptApiSecurity::isSecure(lua_State *L)
{
+#ifndef SERVER
+ auto script = ModApiBase::getScriptApiBase(L);
+ // CSM keeps no globals backup but is always secure
+ if (script->getType() == ScriptingType::Client)
+ return true;
+#endif
lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_GLOBALS_BACKUP);
bool secure = !lua_isnil(L, -1);
lua_pop(L, 1);
diff --git a/src/script/lua_api/l_util.cpp b/src/script/lua_api/l_util.cpp
index f774daf97..47a68ad75 100644
--- a/src/script/lua_api/l_util.cpp
+++ b/src/script/lua_api/l_util.cpp
@@ -659,6 +659,9 @@ void ModApiUtil::InitializeClient(lua_State *L, int top)
API_FCT(sha1);
API_FCT(colorspec_to_colorstring);
API_FCT(colorspec_to_bytes);
+
+ LuaSettings::create(L, g_settings, g_settings_path);
+ lua_setfield(L, top, "settings");
}
void ModApiUtil::InitializeAsync(lua_State *L, int top)
diff --git a/src/script/scripting_client.cpp b/src/script/scripting_client.cpp
index 6643a9509..377205379 100644
--- a/src/script/scripting_client.cpp
+++ b/src/script/scripting_client.cpp
@@ -35,6 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "lua_api/l_nodemeta.h"
#include "lua_api/l_localplayer.h"
#include "lua_api/l_camera.h"
+#include "lua_api/l_settings.h"
ClientScripting::ClientScripting(Client *client):
ScriptApiBase(ScriptingType::Client)
@@ -73,6 +74,7 @@ void ClientScripting::InitializeModApi(lua_State *L, int top)
LuaLocalPlayer::Register(L);
LuaCamera::Register(L);
ModChannelRef::Register(L);
+ LuaSettings::Register(L);
ModApiUtil::InitializeClient(L, top);
ModApiClient::Initialize(L, top);