From 32e1cc63f29ca0f0cf9ce91e6a0637cb5553fad9 Mon Sep 17 00:00:00 2001 From: Niklp Date: Sat, 18 May 2024 23:54:53 +0200 Subject: [PATCH] Add node detector blacklist api --- mesecons_detector/init.lua | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/mesecons_detector/init.lua b/mesecons_detector/init.lua index ad8705e..24e17a7 100644 --- a/mesecons_detector/init.lua +++ b/mesecons_detector/init.lua @@ -157,6 +157,23 @@ minetest.register_abm({ -- Node detector -- Detects the node in front of it +local blacklist = { + air = true, + ignore = true, +} + +function mesecon.node_detector_blacklist_add(node) + blacklist[node] = true +end + +function mesecon.node_detector_blacklist_remove(node) + blacklist[node] = nil +end + +function mesecon.node_detector_on_blacklist(node) + return blacklist[node] == true +end + local function node_detector_make_formspec(pos) local meta = minetest.get_meta(pos) if meta:get_string("distance") == "" then meta:set_string("distance", "0") end @@ -198,7 +215,7 @@ local function node_detector_scan(pos) local scan_for = comma_list_to_table(scanname) return (scan_for[frontname]) or - (frontname ~= "air" and frontname ~= "ignore" and scanname == "") + (blacklist[frontname] ~= true and scanname == "") end local function node_detector_send_node_name(pos, node, channel, meta)