Skip to content

Commit

Permalink
add category and description to control definition
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Dec 12, 2023
1 parent de256a5 commit ed6585e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions controls/builtin.lua
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion controls/restart_if_empty.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ed6585e

Please sign in to comment.