From c83da97df549b5e95847b7e2907f192a47c11d3e Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Fri, 2 Dec 2022 20:24:19 +0100 Subject: [PATCH] Add wrench menu to configure search radius --- logic/player_detector.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/logic/player_detector.lua b/logic/player_detector.lua index f189185..51afc0b 100644 --- a/logic/player_detector.lua +++ b/logic/player_detector.lua @@ -20,6 +20,17 @@ local NDEF = function(pos) return (minetest.registered_nodes[techage.get_node_lv local logic = techage.logic local CYCLE_TIME = 1 +local WRENCH_MENU = { + { + type = "dropdown", + choices = "1,2,3,4,5,6,7,8", + name = "radius", + label = S("Radius"), + tooltip = S("Search radius"), + default = "4", + }, +} + local function switch_on(pos, stage) if logic.swap_node(pos, "techage:ta"..stage.."_playerdetector_on") then logic.send_on(pos, M(pos)) @@ -36,7 +47,8 @@ local function scan_for_player(pos) local nvm = techage.get_nvm(pos) local meta = minetest.get_meta(pos) local names = meta:get_string("names") or "" - for _, object in pairs(minetest.get_objects_inside_radius(pos, 4)) do + local radius = meta:contains("radius") and meta:get_int("radius") or 4 + for _, object in pairs(minetest.get_objects_inside_radius(pos, radius)) do if object:is_player() then if names == "" then nvm.player_name = object:get_player_name() @@ -228,6 +240,7 @@ minetest.register_node("techage:ta4_playerdetector_off", { techage.del_mem(pos) end, + ta4_formspec = WRENCH_MENU, paramtype = "light", sunlight_propagates = true, paramtype2 = "facedir", @@ -277,6 +290,7 @@ minetest.register_node("techage:ta4_playerdetector_on", { techage.del_mem(pos) end, + ta4_formspec = WRENCH_MENU, paramtype = "light", sunlight_propagates = true, paramtype2 = "facedir",