22-- Detects entitys in a certain radius
33-- The radius can be changes by right-click (by default 6)
44
5+ local MAX_RADIUS = moremesecons .setting (" entity_detector" , " max_radius" , 16 , 0 )
6+
57local function make_formspec (meta )
68 meta :set_string (" formspec" , " size[9,5]" ..
79 " 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)
2628 meta :set_string (" digiline_channel" , fields .digiline_channel )
2729 local r = tonumber (fields .radius )
2830 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 ))
3132 end
3233end
3334
@@ -37,8 +38,7 @@ local object_detector_scan = function (pos)
3738 local scanname = meta :get_string (" scanname" )
3839 local scan_all = scanname == " "
3940 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 )
4242 for _ ,obj in pairs (minetest .get_objects_inside_radius (pos , radius )) do
4343 local luaentity = obj :get_luaentity ()
4444 if luaentity then
@@ -62,7 +62,7 @@ local object_detector_digiline = {
6262 action = function (pos , node , channel , msg )
6363 local meta = minetest .get_meta (pos )
6464 local active_channel = meta :get_string (" digiline_channel" )
65- if channel ~= active_channel then
65+ if channel ~= active_channel or type ( msg ) ~= " string " then
6666 return
6767 end
6868 meta :set_string (" scanname" , msg )
0 commit comments