From bf6adf5a09577fb739d61cadc6155db88e1fe903 Mon Sep 17 00:00:00 2001 From: mazes 80 <1608580+mazes-80@users.noreply.github.com> Date: Sat, 18 Feb 2023 01:59:13 +0100 Subject: [PATCH] Settings: add way to disable sharing drawers --- lua/api.lua | 6 ++++++ lua/visual.lua | 4 ++-- settingtypes.txt | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lua/api.lua b/lua/api.lua index a451b91..128fd84 100755 --- a/lua/api.lua +++ b/lua/api.lua @@ -45,6 +45,8 @@ else x_offset = 0.5 end +drawers.shared = minetest.settings:get_bool("drawers.shared", true) + local drawers_formspec_data = {} local drawer_formspec = "size[9,7]" .. "list[context;upgrades;2,0.5;5,1;]" .. @@ -58,6 +60,10 @@ local drawer_formspec = "size[9,7]" .. drawers.get_upgrade_slots_bg(2, 0.5) drawers.get_drawer_formspec = function(pos) + if not drawers.shared then + return drawers.drawer_formspec + end + local shared if minetest.get_meta(pos):get_string("shared") == "true" then shared = "true" diff --git a/lua/visual.lua b/lua/visual.lua index 9d7190d..16d34e7 100755 --- a/lua/visual.lua +++ b/lua/visual.lua @@ -152,7 +152,7 @@ core.register_entity("drawers:visual", { on_rightclick = function(self, clicker) if core.is_protected(self.drawer_pos, clicker:get_player_name()) and - minetest.get_meta(self.drawer_pos):get_string("shared") ~= "true" then + ( not drawers.shared or minetest.get_meta(self.drawer_pos):get_string("shared") ~= "true" ) then core.record_protection_violation(self.drawer_pos, clicker:get_player_name()) return end @@ -216,7 +216,7 @@ core.register_entity("drawers:visual", { end local add_stack = not puncher:get_player_control().sneak if core.is_protected(self.drawer_pos, puncher:get_player_name()) and - minetest.get_meta(self.drawer_pos):get_string("shared") ~= "true" then + ( not drawers.shared or minetest.get_meta(self.drawer_pos):get_string("shared") ~= "true" ) then core.record_protection_violation(self.drawer_pos, puncher:get_player_name()) return end diff --git a/settingtypes.txt b/settingtypes.txt index e69de29..b6f5611 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -0,0 +1 @@ +drawers.shared (Enable sharing drawers) bool true