From 6c0dd2d31a9aed3b5615ac7fbb86e43cc2fe6bf2 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Fri, 17 Feb 2017 23:07:25 -0500 Subject: [PATCH] use unified dyes' rotation correction functions --- homedecor/bedroom.lua | 4 ++-- homedecor/books.lua | 4 ++-- homedecor/furniture.lua | 6 +++--- homedecor/init.lua | 29 ----------------------------- homedecor/lighting.lua | 8 ++++---- homedecor/shutters.lua | 4 ++-- homedecor/window_treatments.lua | 4 ++-- lrfurn/armchairs.lua | 2 +- lrfurn/init.lua | 9 --------- lrfurn/longsofas.lua | 2 +- lrfurn/sofas.lua | 2 +- 11 files changed, 18 insertions(+), 56 deletions(-) diff --git a/homedecor/bedroom.lua b/homedecor/bedroom.lua index 1a7e42f8..9dd42ea8 100644 --- a/homedecor/bedroom.lua +++ b/homedecor/bedroom.lua @@ -51,7 +51,7 @@ homedecor.register("bed_regular", { sounds = default.node_sound_wood_defaults(), on_rotate = screwdriver.disallow, after_place_node = function(pos, placer, itemstack, pointed_thing) - homedecor.fix_rotation_nsew(pos, placer, itemstack, pointed_thing) + unifieddyes.fix_rotation_nsew(pos, placer, itemstack, pointed_thing) if not placer:get_player_control().sneak then return homedecor.bed_expansion(pos, placer, itemstack, pointed_thing) end @@ -123,7 +123,7 @@ homedecor.register("bed_kingsize", { node_box = kbed_cbox, sounds = default.node_sound_wood_defaults(), on_rotate = screwdriver.disallow, - after_place_node = homedecor.fix_rotation_nsew, + after_place_node = unifieddyes.fix_rotation_nsew, after_dig_node = function(pos, oldnode, oldmetadata, digger) local inv = digger:get_inventory() if digger:get_player_control().sneak and inv:room_for_item("main", "bed_regular 1") then diff --git a/homedecor/books.lua b/homedecor/books.lua index a2213ac4..891a6ef1 100644 --- a/homedecor/books.lua +++ b/homedecor/books.lua @@ -83,7 +83,7 @@ homedecor.register("book", { if not homedecor.expect_infinite_stacks then itemstack:take_item() end - homedecor.fix_rotation_nsew(pos, placer, itemstack, pointed_thing) + unifieddyes.fix_rotation_nsew(pos, placer, itemstack, pointed_thing) return itemstack end, on_dig = book_dig, @@ -105,7 +105,7 @@ homedecor.register("book_open", { walkable = false, paramtype2 = "colorwallmounted", palette = "unifieddyes_palette_colorwallmounted.png", - after_place_node = homedecor.fix_rotation_nsew, + after_place_node = unifieddyes.fix_rotation_nsew, after_dig_node = unifieddyes.after_dig_node, on_dig = book_dig, on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) diff --git a/homedecor/furniture.lua b/homedecor/furniture.lua index 30e8e067..20c76fbe 100644 --- a/homedecor/furniture.lua +++ b/homedecor/furniture.lua @@ -58,7 +58,7 @@ homedecor.register("kitchen_chair_wood", { collision_box = kc_cbox, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, ud_param2_colorable = 1}, sounds = default.node_sound_wood_defaults(), - after_place_node = homedecor.fix_rotation_nsew, + after_place_node = unifieddyes.fix_rotation_nsew, on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) pos.y = pos.y+0 -- where do I put my ass ? homedecor.sit(pos, node, clicker) @@ -80,7 +80,7 @@ homedecor.register("kitchen_chair_padded", { collision_box = kc_cbox, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, ud_param2_colorable = 1}, sounds = default.node_sound_wood_defaults(), - after_place_node = homedecor.fix_rotation_nsew, + after_place_node = unifieddyes.fix_rotation_nsew, after_dig_node = unifieddyes.after_dig_node, on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) pos.y = pos.y+0 -- where do I put my ass ? @@ -103,7 +103,7 @@ homedecor.register("armchair", { groups = {snappy=3, ud_param2_colorable = 1}, sounds = default.node_sound_wood_defaults(), node_box = ac_cbox, - after_place_node = homedecor.fix_rotation_nsew, + after_place_node = unifieddyes.fix_rotation_nsew, after_dig_node = unifieddyes.after_dig_node, }) diff --git a/homedecor/init.lua b/homedecor/init.lua index f4c6ed6a..666724c6 100644 --- a/homedecor/init.lua +++ b/homedecor/init.lua @@ -61,35 +61,6 @@ function homedecor.find_ceiling(itemstack, placer, pointed_thing) return isceiling, pos 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 - --- use this when you have a "wallmounted" node that should never be oriented --- to floor or ceiling (e.g. a desk lamp) - -function homedecor.fix_rotation_nsew(pos, placer, itemstack, pointed_thing) - local node = minetest.get_node(pos) - local yaw = placer:get_look_yaw() - local dir = minetest.yaw_to_dir(yaw) - local fdir = minetest.dir_to_wallmounted(dir) - minetest.swap_node(pos, { name = node.name, param2 = fdir }) -end - screwdriver = screwdriver or {} homedecor.plain_wood = { name = "homedecor_generic_wood_plain.png", color = 0xffa76820 } diff --git a/homedecor/lighting.lua b/homedecor/lighting.lua index 62a88a94..8fbc68b4 100644 --- a/homedecor/lighting.lua +++ b/homedecor/lighting.lua @@ -35,7 +35,7 @@ minetest.register_node("homedecor:glowlight_half", { groups = { snappy = 3, ud_param2_colorable = 1 }, light_source = default.LIGHT_MAX, sounds = default.node_sound_glass_defaults(), - after_place_node = homedecor.fix_rotation, + after_place_node = unifieddyes.fix_rotation, after_dig_node = unifieddyes.after_dig_node }) @@ -63,7 +63,7 @@ minetest.register_node("homedecor:glowlight_quarter", { groups = { snappy = 3, ud_param2_colorable = 1 }, light_source = default.LIGHT_MAX-1, sounds = default.node_sound_glass_defaults(), - after_place_node = homedecor.fix_rotation, + after_place_node = unifieddyes.fix_rotation, after_dig_node = unifieddyes.after_dig_node }) @@ -91,7 +91,7 @@ minetest.register_node("homedecor:glowlight_small_cube", { groups = { snappy = 3, ud_param2_colorable = 1 }, light_source = default.LIGHT_MAX-1, sounds = default.node_sound_glass_defaults(), - after_place_node = homedecor.fix_rotation, + after_place_node = unifieddyes.fix_rotation, after_dig_node = unifieddyes.after_dig_node }) @@ -493,7 +493,7 @@ homedecor.register("desk_lamp", { node_box = dlamp_cbox, walkable = false, groups = {snappy=3, ud_param2_colorable = 1}, - after_place_node = homedecor.fix_rotation_nsew, + after_place_node = unifieddyes.fix_rotation_nsew, after_dig_node = unifieddyes.after_dig_node }) diff --git a/homedecor/shutters.lua b/homedecor/shutters.lua index ab1321d9..b463021a 100644 --- a/homedecor/shutters.lua +++ b/homedecor/shutters.lua @@ -38,7 +38,7 @@ homedecor.register("shutter", { sounds = default.node_sound_wood_defaults(), selection_box = shutter_cbox, node_box = shutter_cbox, - after_place_node = homedecor.fix_rotation, + after_place_node = unifieddyes.fix_rotation, after_dig_node = unifieddyes.after_dig_node }) @@ -54,7 +54,7 @@ homedecor.register("shutter_colored", { sounds = default.node_sound_wood_defaults(), selection_box = shutter_cbox, node_box = shutter_cbox, - after_place_node = homedecor.fix_rotation, + after_place_node = unifieddyes.fix_rotation, after_dig_node = unifieddyes.after_dig_node, drop = "homedecor:shutter" }) diff --git a/homedecor/window_treatments.lua b/homedecor/window_treatments.lua index 06328d3b..df9dadf6 100644 --- a/homedecor/window_treatments.lua +++ b/homedecor/window_treatments.lua @@ -113,7 +113,7 @@ minetest.register_node("homedecor:curtain_closed", { palette = "unifieddyes_palette_colorwallmounted.png", selection_box = { type = "wallmounted" }, after_dig_node = unifieddyes.after_dig_node, - after_place_node = homedecor.fix_rotation, + after_place_node = unifieddyes.fix_rotation, on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) local topnode = minetest.get_node({x=pos.x, y=pos.y+1.0, z=pos.z}) if string.find(topnode.name, "homedecor:curtainrod") then @@ -139,7 +139,7 @@ minetest.register_node("homedecor:curtain_open", { palette = "unifieddyes_palette_colorwallmounted.png", selection_box = { type = "wallmounted" }, after_dig_node = unifieddyes.after_dig_node, - after_place_node = homedecor.fix_rotation, + after_place_node = unifieddyes.fix_rotation, on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) local topnode = minetest.get_node({x=pos.x, y=pos.y+1.0, z=pos.z}) if string.find(topnode.name, "homedecor:curtainrod") then diff --git a/lrfurn/armchairs.lua b/lrfurn/armchairs.lua index 4fdb5127..b36638ec 100644 --- a/lrfurn/armchairs.lua +++ b/lrfurn/armchairs.lua @@ -23,7 +23,7 @@ minetest.register_node("lrfurn:armchair", { groups = {snappy=3, ud_param2_colorable = 1}, sounds = default.node_sound_wood_defaults(), node_box = armchair_cbox, - after_place_node = lrfurn.fix_rotation, + after_place_node = unifieddyes.fix_rotation, after_dig_node = unifieddyes.after_dig_node, on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) if not clicker:is_player() then diff --git a/lrfurn/init.lua b/lrfurn/init.lua index 1074482e..b529b632 100644 --- a/lrfurn/init.lua +++ b/lrfurn/init.lua @@ -58,15 +58,6 @@ function lrfurn.check_forward(pos, fdir, long, placer) return true end -function lrfurn.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) - local fdir = minetest.dir_to_wallmounted(dir) - - minetest.swap_node(pos, { name = node.name, param2 = fdir }) -end - dofile(minetest.get_modpath("lrfurn").."/longsofas.lua") dofile(minetest.get_modpath("lrfurn").."/sofas.lua") dofile(minetest.get_modpath("lrfurn").."/armchairs.lua") diff --git a/lrfurn/longsofas.lua b/lrfurn/longsofas.lua index 3aec1327..ad5681f1 100644 --- a/lrfurn/longsofas.lua +++ b/lrfurn/longsofas.lua @@ -24,7 +24,7 @@ minetest.register_node("lrfurn:longsofa", { node_box = longsofa_cbox, on_rotate = screwdriver.disallow, after_place_node = function(pos, placer, itemstack, pointed_thing) - lrfurn.fix_rotation(pos, placer, itemstack, pointed_thing) + unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing) if minetest.is_protected(pos, placer:get_player_name()) then return true end local fdir = minetest.dir_to_facedir(placer:get_look_dir(), false) diff --git a/lrfurn/sofas.lua b/lrfurn/sofas.lua index 6bdc317f..157481a4 100644 --- a/lrfurn/sofas.lua +++ b/lrfurn/sofas.lua @@ -24,7 +24,7 @@ minetest.register_node("lrfurn:sofa", { node_box = sofa_cbox, on_rotate = screwdriver.disallow, after_place_node = function(pos, placer, itemstack, pointed_thing) - lrfurn.fix_rotation(pos, placer, itemstack, pointed_thing) + unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing) if minetest.is_protected(pos, placer:get_player_name()) then return true end local fdir = minetest.dir_to_facedir(placer:get_look_dir(), false)