From 00f61dfb81100094b64de06ca4e1ef73ef8bcd47 Mon Sep 17 00:00:00 2001
From: Tim <t4im@users.noreply.github.com>
Date: Fri, 30 Jan 2015 05:09:20 +0100
Subject: [PATCH] rewrite extractor dye recipes, adding a few dyes and making it work better with the dye mod also preventing any issues if it is being run in a game without it

---
 technic/machines/register/common.lua |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/technic/machines/register/common.lua b/technic/machines/register/common.lua
index a3702ab..d68be14 100644
--- a/technic/machines/register/common.lua
+++ b/technic/machines/register/common.lua
@@ -52,10 +52,7 @@
 			local item0 = stack:to_table()
 			if item0 then 
 				item0["count"] = "1"
-				local item1 = pipeworks.tube_item({x=pos.x, y=pos.y, z=pos.z}, item0)
-				item1:get_luaentity().start_pos = {x=pos.x, y=pos.y, z=pos.z}
-				item1:setvelocity({x=x_velocity, y=0, z=z_velocity})
-				item1:setacceleration({x=0, y=0, z=0})
+				technic.tube_inject_item(pos, pos, vector.new(x_velocity, 0, z_velocity), item0)
 				stack:take_item(1)
 				inv:set_stack(output_name, i, stack)
 				return
@@ -104,12 +101,11 @@
 	if node.param2 == 0 then pos1.x = pos1.x + 1  x_velocity =  1 end
 
 	local output_tube_connected = false
-	local meta1 = minetest.get_meta(pos1) 
-	if meta1:get_int("tubelike") == 1 then
+	local node1 = minetest.get_node(pos1) 
+	if minetest.get_item_group(node1.name, "tubedevice") > 0 then
 		output_tube_connected = true
 	end
-	tube_time = meta:get_int("tube_time")
-	tube_time = tube_time + tube_upgrade
+	local tube_time = meta:get_int("tube_time") + tube_upgrade
 	if tube_time >= 2 then
 		tube_time = 0
 		if output_tube_connected then
@@ -125,8 +121,10 @@
 	local inv = meta:get_inventory()
 	if not inv:is_empty("src") or not inv:is_empty("dst") or
 	   not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
-		minetest.chat_send_player(player:get_player_name(),
-			S("Machine cannot be removed because it is not empty"))
+		if player then
+			minetest.chat_send_player(player:get_player_name(),
+				S("Machine cannot be removed because it is not empty"))
+		end
 		return false
 	else
 		return true

--
Gitblit v1.8.0