From 38e85e9775b132b0ce504d8d795632668eb47852 Mon Sep 17 00:00:00 2001
From: Zefram <zefram@fysh.org>
Date: Wed, 13 Aug 2014 03:45:44 +0200
Subject: [PATCH] Manual section on uranium enrichment

---
 technic/machines/register/common.lua |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/technic/machines/register/common.lua b/technic/machines/register/common.lua
index 8aab96e..a3702ab 100644
--- a/technic/machines/register/common.lua
+++ b/technic/machines/register/common.lua
@@ -37,12 +37,16 @@
 end
 
 
-function technic.send_items(pos, x_velocity, z_velocity)
+function technic.send_items(pos, x_velocity, z_velocity, output_name)
 	-- Send items on their way in the pipe system.
+	if output_name == nil then
+		output_name = "dst"
+	end
+	
 	local meta = minetest.get_meta(pos) 
 	local inv = meta:get_inventory()
 	local i = 0
-	for _, stack in ipairs(inv:get_list("dst")) do
+	for _, stack in ipairs(inv:get_list(output_name)) do
 		i = i + 1
 		if stack then
 			local item0 = stack:to_table()
@@ -53,7 +57,7 @@
 				item1:setvelocity({x=x_velocity, y=0, z=z_velocity})
 				item1:setacceleration({x=0, y=0, z=0})
 				stack:take_item(1)
-				inv:set_stack("dst", i, stack)
+				inv:set_stack(output_name, i, stack)
 				return
 			end
 		end
@@ -67,21 +71,25 @@
 	if meta:get_int("cook_time") < result.time / speed then
 		return
 	end
-	local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
+	local result
+	local afterfuel
+	result, afterfuel = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
 
 	if result and result.item then
 		meta:set_int("cook_time", 0)
 		-- check if there's room for output in "dst" list
 		if inv:room_for_item("dst", result.item) then
-			srcstack = inv:get_stack("src", 1)
-			srcstack:take_item()
-			inv:set_stack("src", 1, srcstack)
+			inv:set_stack("src", 1, afterfuel.items[1])
 			inv:add_item("dst", result.item)
 		end
 	end
 end
 
-function technic.handle_machine_pipeworks(pos, tube_upgrade)
+function technic.handle_machine_pipeworks(pos, tube_upgrade, send_function)
+	if send_function == nil then
+		send_function = technic.send_items
+	end
+	
 	local node = minetest.get_node(pos)
 	local meta = minetest.get_meta(pos)
 	local inv = meta:get_inventory()
@@ -105,7 +113,7 @@
 	if tube_time >= 2 then
 		tube_time = 0
 		if output_tube_connected then
-			technic.send_items(pos, x_velocity, z_velocity)
+			send_function(pos, x_velocity, z_velocity)
 		end
 	end
 	meta:set_int("tube_time", tube_time)

--
Gitblit v1.8.0