From e008aed60c3e4e5875c94617a6cc6d588f283582 Mon Sep 17 00:00:00 2001
From: FaceDeer <derksenmobile@gmail.com>
Date: Thu, 12 Jan 2017 00:50:17 -0700
Subject: Update axle to new layout class, drop dug items in the right place

---
 class_layout.lua             |   4 +++-
 node_axle.lua                |   8 ++++----
 textures/digtron_builder.png | Bin 783 -> 835 bytes
 util_execute_cycle.lua       |  10 +++++-----
 4 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/class_layout.lua b/class_layout.lua
index b7311c5..85beba3 100644
--- a/class_layout.lua
+++ b/class_layout.lua
@@ -15,7 +15,9 @@ local get_node_image = function(pos, node)
 		local build_item = node_image.meta.inventory.main[1]
 		if build_item ~= "" then
 			local build_item_def = minetest.registered_nodes[ItemStack(build_item):get_name()]
-			node_image.build_item_paramtype2 = build_item_def.paramtype2
+			if build_item_def ~= nil then
+				node_image.build_item_paramtype2 = build_item_def.paramtype2
+			end
 		end
 	end
 	return node_image
diff --git a/node_axle.lua b/node_axle.lua
index 9e62b07..ab36c97 100644
--- a/node_axle.lua
+++ b/node_axle.lua
@@ -36,10 +36,10 @@ minetest.register_node("digtron:axle", {
 			-- Been too soon since last time the digtron rotated.
 			return
 		end
-		local image = digtron.get_layout_image(pos, clicker)
-		digtron.rotate_layout_image(image, node.param2)
-		if digtron.can_write_layout_image(image) then
-			digtron.write_layout_image(image)
+		local image = DigtronLayout.create(pos, clicker)
+		image:rotate_layout_image(node.param2)
+		if image:can_write_layout_image() then
+			image:write_layout_image()
 			
 			minetest.sound_play("whirr", {gain=1.0, pos=pos})
 			meta = minetest.get_meta(pos)
diff --git a/textures/digtron_builder.png b/textures/digtron_builder.png
index 446b76d..60fd68e 100644
Binary files a/textures/digtron_builder.png and b/textures/digtron_builder.png differ
diff --git a/util_execute_cycle.lua b/util_execute_cycle.lua
index 42bf410..316a003 100644
--- a/util_execute_cycle.lua
+++ b/util_execute_cycle.lua
@@ -221,11 +221,6 @@ digtron.execute_dig_cycle = function(pos, clicker)
 	-- All tests passed, ready to go for real!
 	minetest.sound_play("construction", {gain=1.0, pos=pos})
 
-	-- store or drop the products of the digger heads
-	for _, itemname in pairs(items_dropped) do
-		digtron.place_in_inventory(itemname, layout.inventories, pos)
-	end
-
 	-- if the player is standing within the array or next to it, move him too.
 	local move_player = move_player_test(layout, clicker)
 	
@@ -250,6 +245,11 @@ digtron.execute_dig_cycle = function(pos, clicker)
 		clicker:moveto(digtron.find_new_pos(clicker:getpos(), facing), true)
 	end
 	
+	-- store or drop the products of the digger heads
+	for _, itemname in pairs(items_dropped) do
+		minetest.debug("placing in inventory", itemname)
+		digtron.place_in_inventory(itemname, layout.inventories, oldpos)
+	end
 	
 	local building_fuel_cost = 0
 	local strange_failure = false
-- 
cgit v1.2.3