1
0
Fork 0

Add `.fast`, `.fly`, `.noclip` and `.pitch` chatcommands (#120)

merge-requests/1/head
luk3yx 2023-02-04 09:32:07 +13:00 committed by mckaygerhard
parent eb122a4e80
commit 16a9de2fe2
1 changed files with 24 additions and 0 deletions

View File

@ -5,3 +5,27 @@ function core.setting_get_pos(name)
end
return core.string_to_pos(value)
end
local function register_toggle_cmd(name, cmd, setting, no_priv)
core.register_chatcommand(cmd, {
description = "Toggles " .. name,
func = function()
if core.settings:get_bool(setting) then
core.settings:set_bool(setting, false)
return true, core.gettext(name .. " disabled")
end
core.settings:set_bool(setting, true)
local msg = name .. " enabled"
if not no_priv and not core.get_privilege_list()[cmd] then
msg = ("%s (note: no '%s' privilege)"):format(msg, cmd)
end
return true, core.gettext(msg)
end,
})
end
register_toggle_cmd("Fast mode", "fast", "fast_move")
register_toggle_cmd("Fly mode", "fly", "free_move")
register_toggle_cmd("Noclip mode", "noclip", "noclip")
register_toggle_cmd("Pitch move mode", "pitch", "pitch_move", true)