mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-07-01 15:20:23 +02:00
Update init.lua
This commit is contained in:
@ -27,11 +27,10 @@ local function object_detector_on_receive_fields(pos, formname, fields, sender)
|
|||||||
if owner ~= "" and sender:get_player_name() ~= owner then
|
if owner ~= "" and sender:get_player_name() ~= owner then
|
||||||
minetest.chat_send_player(sender:get_player_name(), "This detector is owned by "..owner.."!")
|
minetest.chat_send_player(sender:get_player_name(), "This detector is owned by "..owner.."!")
|
||||||
return
|
return
|
||||||
else
|
end
|
||||||
meta:set_string("scanname", fields.scanname)
|
meta:set_string("scanname", fields.scanname)
|
||||||
meta:set_string("digiline_channel", fields.digiline_channel)
|
meta:set_string("digiline_channel", fields.digiline_channel)
|
||||||
object_detector_make_formspec(pos)
|
object_detector_make_formspec(pos)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- returns true if player was found, false if not
|
-- returns true if player was found, false if not
|
||||||
@ -43,10 +42,9 @@ local function object_detector_scan(pos)
|
|||||||
|
|
||||||
local scanname = minetest.get_meta(pos):get_string("scanname")
|
local scanname = minetest.get_meta(pos):get_string("scanname")
|
||||||
local sep = "," -- Begin code to split scanname into array
|
local sep = "," -- Begin code to split scanname into array
|
||||||
local t={} ; i=1
|
local t={}
|
||||||
for str in string.gmatch(scanname, "([^"..sep.."]+)") do
|
for str in string.gmatch(scanname, "([^"..sep.."]+)") do
|
||||||
t[i] = str:gsub("%s+", "")
|
t[str:gsub("%s+", "")] = true
|
||||||
i = i + 1
|
|
||||||
end -- end split code
|
end -- end split code
|
||||||
local every_player = scanname == ""
|
local every_player = scanname == ""
|
||||||
for _, obj in pairs(objs) do
|
for _, obj in pairs(objs) do
|
||||||
@ -54,13 +52,12 @@ local function object_detector_scan(pos)
|
|||||||
local foundname = obj:get_player_name()
|
local foundname = obj:get_player_name()
|
||||||
|
|
||||||
if foundname ~= "" then
|
if foundname ~= "" then
|
||||||
for l = 1, i do
|
for _ in pairs(t) do
|
||||||
if (foundname == t[l] and foundname ~= "") or (foundname ~= "" and scanname == "") then
|
if t[foundname] then return true end
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- return true if scanning for any player or if specific playername was detected
|
|
||||||
end
|
if scanname == "" then return true end -- Return true if no player name was specified
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@ -190,7 +187,7 @@ local function node_detector_scan(pos)
|
|||||||
distance = 0
|
distance = 0
|
||||||
end
|
end
|
||||||
local frontname = minetest.get_node(
|
local frontname = minetest.get_node(
|
||||||
vector.subtract(pos, minetest.facedir_to_dir(node.param2))
|
vector.subtract(pos, vector.multiply(minetest.facedir_to_dir(node.param2), distance+1))
|
||||||
).name
|
).name
|
||||||
local scanname = minetest.get_meta(pos):get_string("scanname")
|
local scanname = minetest.get_meta(pos):get_string("scanname")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user