diff --git a/init.lua b/init.lua index 663b6c7..72f48d0 100644 --- a/init.lua +++ b/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, })