Start implementing dynamic rules/tuning

This commit is contained in:
teknomunk 2024-05-30 06:36:22 -05:00
parent 4dc5d0939c
commit 80ca5fa0c0
2 changed files with 43 additions and 0 deletions

View file

@ -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("<setting> <value>"),
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 <setting> <value>")
end
end
})

View file

@ -0,0 +1,3 @@
name = vl_tuning
author = teknomunk
description = Framework for dynamic tuning and game rules