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,12 +27,11 @@ local function object_detector_on_receive_fields(pos, formname, fields, sender)
|
||||
if owner ~= "" and sender:get_player_name() ~= owner then
|
||||
minetest.chat_send_player(sender:get_player_name(), "This detector is owned by "..owner.."!")
|
||||
return
|
||||
else
|
||||
end
|
||||
meta:set_string("scanname", fields.scanname)
|
||||
meta:set_string("digiline_channel", fields.digiline_channel)
|
||||
object_detector_make_formspec(pos)
|
||||
end
|
||||
end
|
||||
|
||||
-- returns true if player was found, false if not
|
||||
local function object_detector_scan(pos)
|
||||
@ -43,10 +42,9 @@ 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={} ; i=1
|
||||
local t={}
|
||||
for str in string.gmatch(scanname, "([^"..sep.."]+)") do
|
||||
t[i] = str:gsub("%s+", "")
|
||||
i = i + 1
|
||||
t[str:gsub("%s+", "")] = true
|
||||
end -- end split code
|
||||
local every_player = scanname == ""
|
||||
for _, obj in pairs(objs) do
|
||||
@ -54,13 +52,12 @@ local function object_detector_scan(pos)
|
||||
local foundname = obj:get_player_name()
|
||||
|
||||
if foundname ~= "" then
|
||||
for l = 1, i do
|
||||
if (foundname == t[l] and foundname ~= "") or (foundname ~= "" and scanname == "") then
|
||||
return true
|
||||
for _ in pairs(t) do
|
||||
if t[foundname] then return true 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
|
||||
|
||||
return false
|
||||
@ -190,7 +187,7 @@ local function node_detector_scan(pos)
|
||||
distance = 0
|
||||
end
|
||||
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
|
||||
local scanname = minetest.get_meta(pos):get_string("scanname")
|
||||
|
||||
|
Reference in New Issue
Block a user