Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/scripting
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-11-02 08:09:51 +1100
committerKae <80987908+Novaenia@users.noreply.github.com>2023-11-02 08:09:51 +1100
commit2cf97d763c7a398854aafdc24cddba7c20d0f701 (patch)
treee9ee5811a5e61a0bc611128b5de4390287d0d609 /source/game/scripting
parent213ce4bc0f01fb69229b837b8c4a9e59e8ea8976 (diff)
add root configuration getters & setters
Diffstat (limited to 'source/game/scripting')
-rw-r--r--source/game/scripting/StarRootLuaBindings.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/source/game/scripting/StarRootLuaBindings.cpp b/source/game/scripting/StarRootLuaBindings.cpp
index de70950..6f8886e 100644
--- a/source/game/scripting/StarRootLuaBindings.cpp
+++ b/source/game/scripting/StarRootLuaBindings.cpp
@@ -169,6 +169,35 @@ LuaCallbacks LuaBindings::makeRootCallbacks() {
return ItemDescriptor(descriptor1).matches(ItemDescriptor(descriptor2), exactMatch.value(false));
});
+ callbacks.registerCallback("getConfiguration", [root](String const& key) -> Json {
+ if (key == "title")
+ throw StarException(strf("Cannot get {}", key));
+ else
+ return root->configuration()->get(key);
+ });
+
+ callbacks.registerCallback("setConfiguration", [root](String const& key, Json const& value) {
+ if (key == "safeScripts" || key == "configurationVersion")
+ throw StarException(strf("Cannot set {}", key));
+ else
+ root->configuration()->set(key, value);
+ });
+
+
+ callbacks.registerCallback("getConfigurationPath", [root](String const& path) -> Json {
+ if (path.beginsWith("title"))
+ throw StarException(strf("Cannot get {}", path));
+ else
+ return root->configuration()->getPath(path);
+ });
+
+ callbacks.registerCallback("setConfigurationPath", [root](String const& path, Json const& value) {
+ if (path.beginsWith("safeScripts") || path.beginsWith("configurationVersion"))
+ throw StarException(strf("Cannot set {}", path));
+ else
+ root->configuration()->setPath(path, value);
+ });
+
return callbacks;
}