From 620a799fb47f06fef8e09e10f779fcf659fe1402 Mon Sep 17 00:00:00 2001
From: Vanessa Ezekowitz <vanessaezekowitz@gmail.com>
Date: Thu, 7 Nov 2013 20:59:50 -0500
Subject: Moretrees' trunks can now be turned sideways when placing, using
 minetest.rotate_and_place()

Requires Minetest git commit 1d856b73 or later.
---
 node_defs.lua | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

(limited to 'node_defs.lua')

diff --git a/node_defs.lua b/node_defs.lua
index 897a3c7..a4f1346 100644
--- a/node_defs.lua
+++ b/node_defs.lua
@@ -40,6 +40,14 @@ for i in ipairs(moretrees.treelist) do
 			is_ground_content = true,
 			groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
 			sounds = default.node_sound_wood_defaults(),
+			on_place = function(itemstack, placer, pointed_thing)
+				local keys=placer:get_player_control()
+				local pos = pointed_thing.under
+				if not moretrees:node_is_owned(pos, placer) then
+					minetest.rotate_and_place(itemstack, placer, pointed_thing,
+						moretrees.expect_infinite_stacks, { invert_wall = keys.sneak })
+				end
+			end
 		})
 
 		minetest.register_node("moretrees:"..treename.."_planks", {
@@ -378,6 +386,14 @@ minetest.register_node("moretrees:rubber_tree_trunk_empty", {
 	groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
 	sounds = default.node_sound_wood_defaults(),
 	paramtype2 = "facedir",
+	on_place = function(itemstack, placer, pointed_thing)
+		local keys=placer:get_player_control()
+		local pos = pointed_thing.under
+		if not moretrees:node_is_owned(pos, placer) then
+			minetest.rotate_and_place(itemstack, placer, pointed_thing,
+				moretrees.expect_infinite_stacks, { invert_wall = keys.sneak })
+		end
+	end
 })
 
 minetest.register_abm({
-- 
cgit v1.2.3