Builtin: Sanity-check /time inputs
This enforces the documented bounds for the /time command.
This commit is contained in:
parent
98f2fc92df
commit
915f986e3d
@ -933,12 +933,11 @@ core.register_chatcommand("time", {
|
|||||||
end
|
end
|
||||||
local hour, minute = param:match("^(%d+):(%d+)$")
|
local hour, minute = param:match("^(%d+):(%d+)$")
|
||||||
if not hour then
|
if not hour then
|
||||||
local new_time = tonumber(param)
|
local new_time = tonumber(param) or -1
|
||||||
if not new_time then
|
if new_time ~= new_time or new_time < 0 or new_time > 24000 then
|
||||||
return false, "Invalid time."
|
return false, "Invalid time (must be between 0 and 24000)."
|
||||||
end
|
end
|
||||||
-- Backward compatibility.
|
core.set_timeofday(new_time / 24000)
|
||||||
core.set_timeofday((new_time % 24000) / 24000)
|
|
||||||
core.log("action", name .. " sets time to " .. new_time)
|
core.log("action", name .. " sets time to " .. new_time)
|
||||||
return true, "Time of day changed."
|
return true, "Time of day changed."
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user