Skip to content

Commit

Permalink
Settings: add way to disable sharing drawers
Browse files Browse the repository at this point in the history
  • Loading branch information
mazes-80 committed Feb 18, 2023
1 parent ead1eb5 commit 0e1b6ac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lua/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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;]" ..
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions lua/visual.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions settingtypes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
drawers.shared (Enable sharing drawers) bool true

0 comments on commit 0e1b6ac

Please sign in to comment.