From 0e957733e7fd88092c644420ed5ff87587cbbf80 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Fri, 9 Jun 2023 14:16:09 +0200 Subject: [PATCH] Allow to disable the LBM due to needed computing time --- robot.lua | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/robot.lua b/robot.lua index 72ef3a2..dfb4561 100644 --- a/robot.lua +++ b/robot.lua @@ -3,7 +3,7 @@ Signs Bot ========= - Copyright (C) 2019-2021 Joachim Stolberg + Copyright (C) 2019-2023 Joachim Stolberg GPL v3 See LICENSE.txt for more information @@ -13,6 +13,7 @@ ]]-- local lib = signs_bot.lib +local enable_LBM = minetest.settings:get_bool("signs_bot_enable_LBM") == true -- Called when robot is started function signs_bot.place_robot(pos1, pos2, param2) @@ -122,21 +123,23 @@ minetest.register_node("signs_bot:robot_foot", { sounds = default.node_sound_metal_defaults(), }) -minetest.register_lbm({ - label = "[signs_bot] Remove lost robots", - name = "signs_bot:lost_robot_remove", - nodenames = {"signs_bot:robot"}, - run_at_every_load = true, - action = function(pos, node) - local found = false - tubelib2.walk_over_all(function(npos, node, mem) - if node.name == "signs_bot:box" and mem.robot_pos and - vector.equals(pos, mem.robot_pos) then - found = true +if enable_LBM then + minetest.register_lbm({ + label = "[signs_bot] Remove lost robots", + name = "signs_bot:lost_robot_remove", + nodenames = {"signs_bot:robot"}, + run_at_every_load = true, + action = function(pos, node) + local found = false + tubelib2.walk_over_all(function(npos, node, mem) + if node.name == "signs_bot:box" and mem.robot_pos and + vector.equals(pos, mem.robot_pos) then + found = true + end + end, "robot_pos") + if not found then + signs_bot.remove_robot({robot_pos = pos}) end - end, "robot_pos") - if not found then - signs_bot.remove_robot({robot_pos = pos}) end - end -}) + }) +end