Minor fix in detectors

This commit is contained in:
number Zero
2017-03-18 01:16:38 +03:00
parent c265b8891f
commit e675f86766

View File

@ -32,22 +32,19 @@ local function object_detector_scan(pos)
local scanname = minetest.get_meta(pos):get_string("scanname")
local sep = "," -- Begin code to split scanname into array
local t={}
local scan_for = {}
for str in string.gmatch(scanname, "([^"..sep.."]+)") do
t[str:gsub("%s+", "")] = true
scan_for[str:gsub("%s+", "")] = true
end -- end split code
local every_player = scanname == ""
for _, obj in pairs(objs) do
-- "" is returned if it is not a player; "" ~= nil; so only handle objects with foundname ~= ""
local foundname = obj:get_player_name()
if foundname ~= "" then
for _ in pairs(t) do
if t[foundname] then return true end
if every_player or scan_for[foundname] then
return true
end
end
if scanname == "" then return true end -- Return true if no player name was specified
end
return false
@ -143,7 +140,6 @@ local function node_detector_make_formspec(pos)
"field[0.3,1.5;2,2;distance;Distance (0-10):;${distance}]"..
"field[2.5,1.5;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]"..
"button_exit[7,0.75;2,3;;Save]")
if not meta:get_string("owner") then meta:set_string("owner", "") end
end
local function node_detector_on_receive_fields(pos, fieldname, fields, sender)
@ -222,7 +218,6 @@ local function after_place_node_detector(pos, placer)
if placer then
minetest.get_meta(pos):set_string("owner", placer:get_player_name())
end
end
minetest.register_node("mesecons_detector:node_detector_off", {