Add .fast
, .fly
, .noclip
and .pitch
chatcommands (#120)
This commit is contained in:
parent
b97d9bf018
commit
28aa79f211
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user