From 80ca5fa0c0f12e37312242bfa4a7c624aecad9d6 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Thu, 30 May 2024 06:36:22 -0500 Subject: [PATCH] Start implementing dynamic rules/tuning --- mods/CORE/vl_tuning/init.lua | 40 ++++++++++++++++++++++++++++++++++++ mods/CORE/vl_tuning/mod.conf | 3 +++ 2 files changed, 43 insertions(+) create mode 100644 mods/CORE/vl_tuning/init.lua create mode 100644 mods/CORE/vl_tuning/mod.conf diff --git a/mods/CORE/vl_tuning/init.lua b/mods/CORE/vl_tuning/init.lua new file mode 100644 index 000000000..a7e7df597 --- /dev/null +++ b/mods/CORE/vl_tuning/init.lua @@ -0,0 +1,40 @@ +local modname = minetest.get_current_modname() +local S = minetest.get_translator(modname) + +local mod = {} +vl_tuning = mod + +local tunables = {} + +function mod.register_tunable(name, default, setting, setting_type) + local tunable = { + [1] = default, + setting = setting, + setting_type = setting_type, + } + if setting then + if setting_type == "bool" then + tunable[1] = minetest.settings:get_bool(.setting) + else + tunable[1] = minetest.settings:get(setting) + end + end +end + +minetest.register_chatcommand("tune", { + description = S("Admin tool to tune settings and game rules"), + params = S(" "), + privs = { debug = true }, + func = function(name, params_raw) + -- Split apart the params + local params = {} + for str in string.gmatch(params_raw, "([^ ]+)") do + params[#params + 1] = str + end + + if #params ~= 2 then + return false, S("Usage: /tune ") + end + end +}) + diff --git a/mods/CORE/vl_tuning/mod.conf b/mods/CORE/vl_tuning/mod.conf new file mode 100644 index 000000000..ad326f776 --- /dev/null +++ b/mods/CORE/vl_tuning/mod.conf @@ -0,0 +1,3 @@ +name = vl_tuning +author = teknomunk +description = Framework for dynamic tuning and game rules