Check for NaN values in settings

This commit is contained in:
upsilon 2017-02-11 15:44:53 +01:00
parent d6e50086c1
commit 676baa4b0b
No known key found for this signature in database
GPG Key ID: A80DAE1F266E1C3C
7 changed files with 24 additions and 8 deletions

View File

@ -2,6 +2,8 @@ local function initialize_data(meta)
local NEAREST_MAX_DISTANCE = tonumber(minetest.setting_get("moremesecons_commandblock.nearest_max_distance")) or 8
if NEAREST_MAX_DISTANCE <= 0 then
NEAREST_MAX_DISTANCE = 1
elseif NEAREST_MAX_DISTANCE ~= NEAREST_MAX_DISTANCE then -- NaN
NEAREST_MAX_DISTANCE = 8
end
local commands = meta:get_string("commands")

View File

@ -19,6 +19,8 @@ local function is_jammed(pos)
local JAMMER_MAX_DISTANCE = tonumber(minetest.setting_get(moresecons_jammer.max_distance)) or 10
if JAMMER_MAX_DISTANCE <= 0 then
JAMMER_MAX_DISTANCE = 1
elseif JAMMER_MAX_DISTANCE ~= JAMMER_MAX_DISTANCE then -- NaN
JAMMER_MAX_DISTANCE = 10
end
local pz,py,px = vector.unpack(pos)

View File

@ -2,6 +2,8 @@ local kill_nearest_player = function(pos)
local MAX_DISTANCE = tonumber(minetest.setting_get("moremesecons_playerkiller.max_distance")) or 8 -- Use this number to set maximal distance to kill
if MAX_DISTANCE <= 0 then
MAX_DISTANCE = 8
elseif MAX_DISTANCE ~= MAX_DISTANCE then -- NaN
MAX_DISTANCE = 8
end
-- Search the nearest player

View File

@ -44,9 +44,11 @@ if use_speech_dispatcher then
end
function sayer_activate(pos)
local MAX_DISTANCE = minetest.setting_get("moremesecons_sayer.max_distance") or 8
local MAX_DISTANCE = tonumber(minetest.setting_get("moremesecons_sayer.max_distance")) or 8
if MAX_DISTANCE <= 0 then
MAX_DISTANCE = 1
elseif MAX_DISTANCE ~= MAX_DISTANCE then -- NaN
MAX_DISTANCE = 8
end
MAX_DISTANCE = MAX_DISTANCE^2
@ -83,9 +85,11 @@ if use_speech_dispatcher then
end
else
function sayer_activate(pos)
local MAX_DISTANCE = minetest.setting_get("moremesecons_sayer.max_distance") or 8
local MAX_DISTANCE = tonumber(minetest.setting_get("moremesecons_sayer.max_distance")) or 8
if MAX_DISTANCE <= 0 then
MAX_DISTANCE = 1
elseif MAX_DISTANCE ~= MAX_DISTANCE then -- NaN
MAX_DISTANCE = 8
end
local tab = {

View File

@ -13,10 +13,14 @@ local teleport_nearest = function(pos)
local MAX_TELEPORTATION_DISTANCE = tonumber(minetest.setting_get("moremesecons_teleporter.max_t2t_distance")) or 50
if MAX_TELEPORTATION_DISTANCE <= 0 then
MAX_TELEPORTATION_DISTANCE = 1
elseif MAX_TELEPORTATION_DISTANCE ~= MAX_TELEPORTATION_DISTANCE then -- NaN
MAX_TELEPORTATION_DISTANCE = 50
end
local MAX_PLAYER_DISTANCE = tonumber(minetest.setting_get("moremesecons_teleporter.max_p2t_distance")) or 25
if MAX_PLAYER_DISTANCE <= 0 then
MAX_PLAYER_DISTANCE = 1
elseif MAX_PLAYER_DISTANCE ~= MAX_PLAYER_DISTANCE then -- NaN
MAX_PLAYER_DISTANCE = 25
end
-- Search the nearest player

View File

@ -117,6 +117,8 @@ function is_jammed(pos)
local JAMMER_MAX_DISTANCE = tonumber(minetest.setting_get("moremesecons_wireless.jammer_max_distance")) or 15
if JAMMER_MAX_DISTANCE <= 0 then
JAMMER_MAX_DISTANCE = 1
elseif JAMMER_MAX_DISTANCE ~= JAMMER_MAX_DISTANCE then -- NaN
JAMMER_MAX_DISTANCE = 15
end
local pz,py,px = vector.unpack(pos)

View File

@ -5,19 +5,19 @@
moremesecons_commandblock.authorized_commands (Authorized commands) string tell
# Maximum distance of the @nearest player
# Any value less than or equal to 0 will be set to 1
# Any value less than or equal to 0 will be changed to 1 and a NaN value will be changed to the default value
moremesecons_commandblock.nearest_max_distance (Nearest player maximum distance) float 8
[Signal Jammer]
# Jammer action range
# Any value less than or equal to 0 will be set to 1
# Any value less than or equal to 0 will be changed to 1 and a NaN value will be changed to the default value
moremesecons_jammer.max_distance (Jammer action range) float 10
[Player Killer]
# Player Killer action range
# Any value less than or equal to 0 will be set to 1
# Any value less than or equal to 0 will be changed to 1 and a NaN value will be changed to the default value
moremesecons_playerkiller.max_distance (Player Killer action range) float 8
[Sayer]
@ -31,13 +31,13 @@ moremesecons_playerkiller.max_distance (Player Killer action range) float 8
moremesecons_sayer.use_speech_dispatcher (Use the Speech Dispatcher) bool true
# Sayer range
# Any value less than or equal to 0 will be set to 1
# Any value less than or equal to 0 will be changed to 1 and a NaN value will be changed to the default value
moremesecons_sayer.max_distance (Range) float 8
[Teleporter]
# Maximum Teleporter To Teleporter distance
# Any value less than or equal to 0 will be set to 1
# Any value less than or equal to 0 will be changed to 1 and a NaN value will be changed to the default value
moremesecons_teleporter.max_t2t_distance (Maximum Teleporter To Teleporter distance) float 50
# Maximum Player To Teleporter distance
@ -47,5 +47,5 @@ moremesecons_teleporter.max_p2t_distance (Maximum Player To Teleporter distance)
[Wireless]
# Wireless Jammer action range
# Any value less than or equal to 0 will be set to 1
# Any value less than or equal to 0 will be changed to 1 and a NaN value will be changed to the default value
moremesecons_wireless.jammer_max_distance (Wireless Jammer action range) float 15