add "itemframes.allow_rotate" setting to allow itemframe item rotation in protected areas.

This commit is contained in:
tenplus1 2023-08-03 08:09:11 +01:00
parent 9f17f744d7
commit 5cced5cb21
3 changed files with 9 additions and 2 deletions

View File

@ -4,6 +4,7 @@ screwdriver = screwdriver or {}
local tmp = {} local tmp = {}
local should_return_item = minetest.settings:get_bool("itemframes.return_item", false) local should_return_item = minetest.settings:get_bool("itemframes.return_item", false)
local log_actions = minetest.settings:get_bool("itemframes.log_actions", false) local log_actions = minetest.settings:get_bool("itemframes.log_actions", false)
local allow_rotate = minetest.settings:get_bool("itemframes.allow_rotate", false)
-- item entity -- item entity
@ -383,7 +384,8 @@ minetest.register_node("itemframes:frame",{
on_punch = function(pos, node, puncher) on_punch = function(pos, node, puncher)
-- rotate item inside frame when holding sneak and punching -- rotate item inside frame when holding sneak and punching
if puncher and puncher:get_player_control().sneak then if puncher and puncher:get_player_control().sneak
and (allow_rotate or not minetest.is_protected(pos, puncher:get_player_name())) then
local p2 = node.param2 local p2 = node.param2
local nx = facedir[p2].nx local nx = facedir[p2].nx
@ -497,7 +499,8 @@ minetest.register_node("itemframes:frame_invis",{
on_punch = function(pos, node, puncher) on_punch = function(pos, node, puncher)
-- rotate item inside frame when holding sneak and punching -- rotate item inside frame when holding sneak and punching
if puncher and puncher:get_player_control().sneak then if puncher and puncher:get_player_control().sneak
and (allow_rotate or not minetest.is_protected(pos, puncher:get_player_name())) then
local p2 = node.param2 local p2 = node.param2
local nx = facedir[p2].nx local nx = facedir[p2].nx

View File

@ -16,6 +16,8 @@ Change 'itemframes.return_item' setting to true if you want items to drop back i
Change 'itemframes.log_actions' setting to true if you want to log player actions when inserting or removing items from a frame or pedestal. Change 'itemframes.log_actions' setting to true if you want to log player actions when inserting or removing items from a frame or pedestal.
Itemframe items can be rotated by holding sneak and punching frame, but in a protected area this is limited to the owner unless "itemframes.allow_rotate" setting is true.
Texture Override Texture Override
---------------- ----------------

View File

@ -3,3 +3,5 @@ itemframes.return_item (return placed item to the player's inventory on right-cl
# if false, inserting and removing items from frames and pedestals will not be logged # if false, inserting and removing items from frames and pedestals will not be logged
itemframes.log_actions (log player actions when using itemframes and pedestals) bool false itemframes.log_actions (log player actions when using itemframes and pedestals) bool false
itemframes.allow_rotate (Allow item rotation in protected areas) bool false