1
0
mirror of https://github.com/mt-mods/homedecor_modpack.git synced 2024-12-22 16:10:18 +01:00

use unified dyes' rotation correction functions

This commit is contained in:
Vanessa Ezekowitz 2017-02-17 23:07:25 -05:00
parent e9477dd45d
commit 6c0dd2d31a
11 changed files with 18 additions and 56 deletions

View File

@ -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

View File

@ -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)

View File

@ -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,
})

View File

@ -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 }

View File

@ -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
})

View File

@ -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"
})

View File

@ -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

View File

@ -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

View File

@ -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")

View File

@ -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)

View File

@ -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)