Fix magnocompass rotation if placed on stair

This commit is contained in:
Wuzzy 2023-02-07 21:47:25 +01:00
parent 3ae44ce19d
commit a25cccd3e1
3 changed files with 15 additions and 6 deletions

View File

@ -94,6 +94,7 @@ This is the list of all groups used for nodes. Note: If no number/rating is spec
* `uses_canonical_compass`: This is used for nodes that can carry a compass. If this group is set, the compass will be
added to the node in "canonical" form, i.e. the needle always faces upwards. Otherwise,
the compass needle is adjusted according to the node position and rotation (wallmounted/facedir).
* `special_magnocompass_node_handling=1`: Node will handle placing a magno compass in a special way (see `rp_nav`)
* `seed`: A farming item that can be planted on the ground to spawn a plant that will grow over time.
Usually this is a seed, but it does not have to be.
* `_attached_node_top=1`: Node attaches to the top of another node. If the node above disappears, the node itself detaches

View File

@ -252,7 +252,11 @@ minetest.register_node("rp_itemshow:frame",{
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = {choppy = 2, dig_immediate = 2, creative_decoblock = 1},
groups = {
choppy = 2, dig_immediate = 2, creative_decoblock = 1,
-- So that placing a magnocompass on it will point
-- the needle to the correct direction
special_magnocompass_place_handling = 1},
sounds = rp_sounds.node_sound_defaults(),
is_ground_content = false,
on_rotate = function(pos, node, user, mode, new_param2)

View File

@ -214,12 +214,16 @@ for c=0,7 do
end
-- Otherwise, adjust the compass needle so it shows to the correct direction
else
local nodedef = minetest.registered_nodes[node.name]
local nodeyaw = 0
if nodedef and (nodedef.paramtype2 == "wallmounted" or nodedef.paramtype2 == "colorwallmounted") then
nodeyaw = minetest.dir_to_yaw(minetest.wallmounted_to_dir(node.param2))
elseif nodedef and (nodedef.paramtype2 == "facedir" or nodedef.paramtype2 == "colorfacedir") then
nodeyaw = minetest.dir_to_yaw(minetest.facedir_to_dir(node.param2))
-- If this group is set, calculate the node's "yaw" and use that
-- for the placed magnocompass
if minetest.get_item_group(node.name, "special_magnocompass_place_handling") == 1 then
local nodedef = minetest.registered_nodes[node.name]
if nodedef and (nodedef.paramtype2 == "wallmounted" or nodedef.paramtype2 == "colorwallmounted") then
nodeyaw = minetest.dir_to_yaw(minetest.wallmounted_to_dir(node.param2))
elseif nodedef and (nodedef.paramtype2 == "facedir" or nodedef.paramtype2 == "colorfacedir") then
nodeyaw = minetest.dir_to_yaw(minetest.facedir_to_dir(node.param2))
end
end
-- Special case: Item frame. Add a little offset for nodepos as
-- the compass entity is at the side of the node rather than the center.