2
2
-- Detects entitys in a certain radius
3
3
-- The radius can be changes by right-click (by default 6)
4
4
5
+ local MAX_RADIUS = moremesecons .setting (" entity_detector" , " max_radius" , 16 , 0 )
6
+
5
7
local function make_formspec (meta )
6
8
meta :set_string (" formspec" , " size[9,5]" ..
7
9
" field[0.3, 0;9,2;scanname;Comma-separated list of the names (itemstring) of entities to scan for (empty for any):;${scanname}]" ..
@@ -26,8 +28,7 @@ local function object_detector_on_receive_fields(pos, _, fields, player)
26
28
meta :set_string (" digiline_channel" , fields .digiline_channel )
27
29
local r = tonumber (fields .radius )
28
30
if r then
29
- local max_radius = moremesecons .setting (" entity_detector" , " max_radius" , 16 , 0 )
30
- meta :set_int (" radius" , math.min (r , max_radius ))
31
+ meta :set_int (" radius" , math.min (r , MAX_RADIUS ))
31
32
end
32
33
end
33
34
@@ -37,8 +38,7 @@ local object_detector_scan = function (pos)
37
38
local scanname = meta :get_string (" scanname" )
38
39
local scan_all = scanname == " "
39
40
local scan_names = scanname :split (' ,' )
40
- local max_radius = moremesecons .setting (" entity_detector" , " max_radius" , 16 , 0 )
41
- local radius = math.min (tonumber (meta :get (" radius" )) or 6 , max_radius )
41
+ local radius = math.min (tonumber (meta :get (" radius" )) or 6 , MAX_RADIUS )
42
42
for _ ,obj in pairs (minetest .get_objects_inside_radius (pos , radius )) do
43
43
local luaentity = obj :get_luaentity ()
44
44
if luaentity then
@@ -62,7 +62,7 @@ local object_detector_digiline = {
62
62
action = function (pos , node , channel , msg )
63
63
local meta = minetest .get_meta (pos )
64
64
local active_channel = meta :get_string (" digiline_channel" )
65
- if channel ~= active_channel then
65
+ if channel ~= active_channel or type ( msg ) ~= " string " then
66
66
return
67
67
end
68
68
meta :set_string (" scanname" , msg )
0 commit comments