summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--castle/init.lua11
-rw-r--r--castle/tapestry.lua6
-rw-r--r--homedecor/bedroom.lua4
-rw-r--r--homedecor/books.lua4
-rw-r--r--homedecor/furniture.lua6
-rw-r--r--homedecor/init.lua29
-rw-r--r--homedecor/lighting.lua8
-rw-r--r--homedecor/shutters.lua4
-rw-r--r--homedecor/window_treatments.lua4
-rw-r--r--ilights/init.lua21
-rw-r--r--lrfurn/armchairs.lua2
-rw-r--r--lrfurn/init.lua9
-rw-r--r--lrfurn/longsofas.lua2
-rw-r--r--lrfurn/sofas.lua2
-rw-r--r--unifieddyes/init.lua29
15 files changed, 51 insertions, 90 deletions
diff --git a/castle/init.lua b/castle/init.lua
index 11b239d..d57967e 100644
--- a/castle/init.lua
+++ b/castle/init.lua
@@ -1,16 +1,5 @@
castle = {}
--- use this when you have a "wallmounted" node that should never be oriented
--- to floor or ceiling (e.g. a tapestry)
-
-function castle.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
-
dofile(minetest.get_modpath("castle").."/pillars.lua")
dofile(minetest.get_modpath("castle").."/arrowslit.lua")
dofile(minetest.get_modpath("castle").."/tapestry.lua")
diff --git a/castle/tapestry.lua b/castle/tapestry.lua
index 59b94b4..75b372a 100644
--- a/castle/tapestry.lua
+++ b/castle/tapestry.lua
@@ -64,7 +64,7 @@ minetest.register_node("castle:tapestry", {
type = "wallmounted",
wall_side = {-0.5,-0.5,0.4375,0.5,1.5,0.5},
},
- after_place_node = castle.fix_rotation_nsew,
+ after_place_node = unifieddyes.fix_rotation_nsew,
after_dig_node = unifieddyes.after_dig_node
})
@@ -93,7 +93,7 @@ minetest.register_node("castle:tapestry_long", {
type = "wallmounted",
wall_side = {-0.5,-0.5,0.4375,0.5,2.5,0.5},
},
- after_place_node = castle.fix_rotation_nsew,
+ after_place_node = unifieddyes.fix_rotation_nsew,
after_dig_node = unifieddyes.after_dig_node
})
@@ -122,7 +122,7 @@ minetest.register_node("castle:tapestry_very_long", {
type = "wallmounted",
wall_side = {-0.5,-0.5,0.4375,0.5,3.5,0.5},
},
- after_place_node = castle.fix_rotation_nsew,
+ after_place_node = unifieddyes.fix_rotation_nsew,
after_dig_node = unifieddyes.after_dig_node
})
diff --git a/homedecor/bedroom.lua b/homedecor/bedroom.lua
index 1a7e42f..9dd42ea 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 a2213ac..891a6ef 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 30e8e06..20c76fb 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 f4c6ed6..666724c 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 62a88a9..8fbc68b 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 ab1321d..b463021 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 06328d3..df9dadf 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/ilights/init.lua b/ilights/init.lua
index bc58629..6f6fdd4 100644
--- a/ilights/init.lua
+++ b/ilights/init.lua
@@ -20,25 +20,6 @@ end
ilights.modpath = minetest.get_modpath("ilights")
--- Helper function to work around an engine bug
-
-function ilights.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
-
-
-- The important stuff!
local lamp_cbox = {
@@ -67,7 +48,7 @@ minetest.register_node("ilights:light", {
light_source = 14,
selection_box = lamp_cbox,
node_box = lamp_cbox,
- after_place_node = ilights.fix_rotation,
+ after_place_node = unifieddyes.fix_rotation,
after_dig_node = unifieddyes.after_dig_node
})
diff --git a/lrfurn/armchairs.lua b/lrfurn/armchairs.lua
index 4fdb512..b36638e 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 1074482..b529b63 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 3aec132..ad5681f 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 6bdc317..157481a 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)
diff --git a/unifieddyes/init.lua b/unifieddyes/init.lua
index 580218a..bc8234f 100644
--- a/unifieddyes/init.lua
+++ b/unifieddyes/init.lua
@@ -93,6 +93,35 @@ local default_dyes = {
-- code borrowed from homedecor
+-- call this function to reset the rotation of a "wallmounted" object on place
+
+function unifieddyes.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/8) then
+ fdir = 0
+ elseif pitch > math.pi/8 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
+
+function unifieddyes.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
+
function unifieddyes.select_node(pointed_thing)
local pos = pointed_thing.under
local node = minetest.get_node_or_nil(pos)