From ed6585e6b98671db58d0b94d2452804cf995002b Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Tue, 12 Dec 2023 13:03:52 +0100 Subject: [PATCH] add `category` and `description` to control definition --- control.lua | 1 + controls/builtin.lua | 4 ++++ controls/restart_if_empty.lua | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/control.lua b/control.lua index 217cd6b..41f0a3c 100644 --- a/control.lua +++ b/control.lua @@ -4,6 +4,7 @@ local controls = {} function mtui.register_control(name, def) + def.category = def.category or "unknown" def.name = name def.modname = def.modname or minetest.get_current_modname() controls[name] = def diff --git a/controls/builtin.lua b/controls/builtin.lua index 93a6f43..133e336 100644 --- a/controls/builtin.lua +++ b/controls/builtin.lua @@ -1,7 +1,9 @@ mtui.register_control("mtui:shutdown", { + category = "builtin", type = "button", label = "Shutdown server", + description = "shuts down the server", action = { set = function() minetest.request_shutdown("planned shutdown") @@ -10,10 +12,12 @@ mtui.register_control("mtui:shutdown", { }) mtui.register_control("mtui:tod", { + category = "builtin", type = "numeric", min = 0, max = 24, label = "Time of day (hour)", + description = "sets the time of day", action = { get = function() -- 1/10 decimal precision diff --git a/controls/restart_if_empty.lua b/controls/restart_if_empty.lua index 01833a6..d151a25 100644 --- a/controls/restart_if_empty.lua +++ b/controls/restart_if_empty.lua @@ -29,8 +29,10 @@ minetest.register_chatcommand("restart_if_empty", { }) mtui.register_control("mtui:restart_if_empty", { + category = "builtin", type = "bool", - label = "Restart as soon as the server is empty", + label = "Restart if empty", + description = "Restart as soon as the server is empty", action = { get = function() return restart