validate settings input strings
This commit is contained in:
parent
0c54e58cbc
commit
cef9f69717
24
init.lua
24
init.lua
|
@ -46,15 +46,31 @@ end)
|
|||
minetest.register_chatcommand("strength", {
|
||||
description = "set max rumble strength (between 0 and 1)",
|
||||
func = function(text)
|
||||
rumble_strength_max = (text)
|
||||
minetest.display_chat_message("max rumble strength set to "..rumble_strength_max)
|
||||
if (string.match((text), "^%d+$")) then
|
||||
rumble_strength_max = (text)
|
||||
minetest.display_chat_message("max rumble strength set to "..rumble_strength_max)
|
||||
else
|
||||
minetest.display_chat_message(minetest.colorize("#FF0", "error: value after .strength should be a positive number"))
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("duration", {
|
||||
description = "set max rumble duration (in seconds)",
|
||||
func = function(text)
|
||||
rumble_duration_max = (text)
|
||||
minetest.display_chat_message("max rumble duration set to "..rumble_duration_max)
|
||||
if (string.match((text), "^%d+$")) then
|
||||
rumble_duration_max = (text)
|
||||
minetest.display_chat_message("max rumble duration set to "..rumble_duration_max)
|
||||
else
|
||||
minetest.display_chat_message(minetest.colorize("#FF0", "error: value after .duration should be a positive number"))
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("settings", {
|
||||
description = "shows current values of settings",
|
||||
func = function()
|
||||
minetest.display_chat_message("max rumble strength: "..rumble_strength_max)
|
||||
minetest.display_chat_message("max rumble duration: "..rumble_duration_max)
|
||||
end,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue