Add wrench menu to configure search radius

This commit is contained in:
Joachim Stolberg 2022-12-02 20:24:19 +01:00
parent 7a4a446d82
commit c83da97df5

View File

@ -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",