forked from mtcontrib/homedecor_modpack
add a function to correct for broken placement rotation
for wallmounted nodes (engine or _game bug), and put it to use.
This commit is contained in:
parent
79e501394a
commit
175724d53c
@ -65,6 +65,24 @@ function homedecor.find_ceiling(itemstack, placer, pointed_thing)
|
|||||||
return isceiling, pos
|
return isceiling, pos
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- call this function to reset the rotation of a "wallmounted" object on place
|
||||||
|
|
||||||
|
function homedecor.fix_rotation(pos, placer, itemstack, pointed_thing)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
local yaw = placer:get_look_yaw()
|
||||||
|
local dir = minetest.yaw_to_dir(yaw-1.5)
|
||||||
|
local pitch = placer:get_look_vertical()
|
||||||
|
|
||||||
|
local fdir = minetest.dir_to_wallmounted(dir)
|
||||||
|
|
||||||
|
if pitch < -(math.pi/4) then
|
||||||
|
fdir = 0
|
||||||
|
elseif pitch > math.pi/4 then
|
||||||
|
fdir = 1
|
||||||
|
end
|
||||||
|
minetest.swap_node(pos, { name = node.name, param2 = fdir })
|
||||||
|
end
|
||||||
|
|
||||||
screwdriver = screwdriver or {}
|
screwdriver = screwdriver or {}
|
||||||
|
|
||||||
homedecor.plain_wood = { name = "homedecor_generic_wood_plain.png", color = 0xffa76820 }
|
homedecor.plain_wood = { name = "homedecor_generic_wood_plain.png", color = 0xffa76820 }
|
||||||
|
@ -41,6 +41,7 @@ minetest.register_node("homedecor:glowlight_half", {
|
|||||||
groups = { snappy = 3 },
|
groups = { snappy = 3 },
|
||||||
light_source = default.LIGHT_MAX,
|
light_source = default.LIGHT_MAX,
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
|
after_place_node = homedecor.fix_rotation,
|
||||||
after_dig_node = unifieddyes.after_dig_node,
|
after_dig_node = unifieddyes.after_dig_node,
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
unifieddyes.on_rightclick(pos, node, clicker,
|
unifieddyes.on_rightclick(pos, node, clicker,
|
||||||
@ -72,6 +73,7 @@ minetest.register_node("homedecor:glowlight_quarter", {
|
|||||||
groups = { snappy = 3 },
|
groups = { snappy = 3 },
|
||||||
light_source = default.LIGHT_MAX-1,
|
light_source = default.LIGHT_MAX-1,
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
|
after_place_node = homedecor.fix_rotation,
|
||||||
after_dig_node = unifieddyes.after_dig_node,
|
after_dig_node = unifieddyes.after_dig_node,
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
unifieddyes.on_rightclick(pos, node, clicker,
|
unifieddyes.on_rightclick(pos, node, clicker,
|
||||||
@ -103,6 +105,7 @@ minetest.register_node("homedecor:glowlight_small_cube", {
|
|||||||
groups = { snappy = 3 },
|
groups = { snappy = 3 },
|
||||||
light_source = default.LIGHT_MAX-1,
|
light_source = default.LIGHT_MAX-1,
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
|
after_place_node = homedecor.fix_rotation,
|
||||||
after_dig_node = unifieddyes.after_dig_node,
|
after_dig_node = unifieddyes.after_dig_node,
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
unifieddyes.on_rightclick(pos, node, clicker,
|
unifieddyes.on_rightclick(pos, node, clicker,
|
||||||
|
@ -114,13 +114,7 @@ minetest.register_node("homedecor:curtain_closed", {
|
|||||||
palette = "unifieddyes_palette_colorwallmounted.png",
|
palette = "unifieddyes_palette_colorwallmounted.png",
|
||||||
selection_box = { type = "wallmounted" },
|
selection_box = { type = "wallmounted" },
|
||||||
after_dig_node = unifieddyes.after_dig_node,
|
after_dig_node = unifieddyes.after_dig_node,
|
||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
after_place_node = homedecor.fix_rotation,
|
||||||
local yaw = placer:get_look_yaw()
|
|
||||||
local dir = minetest.yaw_to_dir(yaw-1.5)
|
|
||||||
local fdir = minetest.dir_to_wallmounted(dir)
|
|
||||||
name = minetest.get_node(pos).name
|
|
||||||
minetest.swap_node(pos, { name = name, param2 = fdir })
|
|
||||||
end,
|
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
local itemname = itemstack:get_name()
|
local itemname = itemstack:get_name()
|
||||||
if string.find(itemname, "dye:") or string.find(itemname, "unifieddyes:") then
|
if string.find(itemname, "dye:") or string.find(itemname, "unifieddyes:") then
|
||||||
@ -151,13 +145,7 @@ minetest.register_node("homedecor:curtain_open", {
|
|||||||
palette = "unifieddyes_palette_colorwallmounted.png",
|
palette = "unifieddyes_palette_colorwallmounted.png",
|
||||||
selection_box = { type = "wallmounted" },
|
selection_box = { type = "wallmounted" },
|
||||||
after_dig_node = unifieddyes.after_dig_node,
|
after_dig_node = unifieddyes.after_dig_node,
|
||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
after_place_node = homedecor.fix_rotation,
|
||||||
local yaw = placer:get_look_yaw()
|
|
||||||
local dir = minetest.yaw_to_dir(yaw-1.5)
|
|
||||||
local fdir = minetest.dir_to_wallmounted(dir)
|
|
||||||
name = minetest.get_node(pos).name
|
|
||||||
minetest.swap_node(pos, { name = name, param2 = fdir })
|
|
||||||
end,
|
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
local itemname = itemstack:get_name()
|
local itemname = itemstack:get_name()
|
||||||
if string.find(itemname, "dye:") or string.find(itemname, "unifieddyes:") then
|
if string.find(itemname, "dye:") or string.find(itemname, "unifieddyes:") then
|
||||||
|
Loading…
Reference in New Issue
Block a user