allow decimal numbers in validation process
This commit is contained in:
parent
cef9f69717
commit
9f45d53a07
12
init.lua
12
init.lua
|
@ -4,7 +4,7 @@
|
|||
|
||||
-- To do list:
|
||||
-- chatcommand to start and stop logging
|
||||
-- chatcommand to write what is being logged into the chat
|
||||
-- chatcommand to toggle to write what is being logged into the chat
|
||||
-- sadist mode
|
||||
-- tnt griefer mode
|
||||
-- move python program to a different directory
|
||||
|
@ -44,10 +44,10 @@ end)
|
|||
|
||||
-- step 5 (commands)
|
||||
minetest.register_chatcommand("strength", {
|
||||
description = "set max rumble strength (between 0 and 1)",
|
||||
description = "set max rumble strength (from 0 to 1)",
|
||||
func = function(text)
|
||||
if (string.match((text), "^%d+$")) then
|
||||
rumble_strength_max = (text)
|
||||
if (string.match((text), "^%d+%.%d+$")) or (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"))
|
||||
|
@ -58,8 +58,8 @@ minetest.register_chatcommand("strength", {
|
|||
minetest.register_chatcommand("duration", {
|
||||
description = "set max rumble duration (in seconds)",
|
||||
func = function(text)
|
||||
if (string.match((text), "^%d+$")) then
|
||||
rumble_duration_max = (text)
|
||||
if (string.match((text), "^%d+%.%d+$")) or (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"))
|
||||
|
|
Loading…
Reference in New Issue