From dc0689018d27a68ae2987194285558b3add09be2 Mon Sep 17 00:00:00 2001
From: Vanessa Dannenberg <vanessa.e.dannenberg@gmail.com>
Date: Sun, 25 Nov 2018 16:10:23 +0100
Subject: [PATCH] move CNC machine into its own mod

---
 technic/register.lua |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/technic/register.lua b/technic/register.lua
index 288db57..8f75b81 100644
--- a/technic/register.lua
+++ b/technic/register.lua
@@ -3,6 +3,7 @@
 
 technic.receiver = "RE"
 technic.producer = "PR"
+technic.producer_receiver = "PR_RE"
 technic.battery  = "BA"
 
 technic.machines    = {}
@@ -11,8 +12,7 @@
 
 
 function technic.register_tier(tier, description)
-	technic.machines[tier]    = {}
-	technic.cables[tier]      = {}
+	technic.machines[tier] = {}
 end
 
 function technic.register_machine(tier, nodename, machine_type)
@@ -44,7 +44,15 @@
 
 -- Wear down a tool depending on the remaining charge.
 function technic.set_RE_wear(itemstack, item_load, max_load)
-	local temp = 65536 - math.floor(item_load / max_load * 65535)
+	if (minetest.registered_items[itemstack:get_name()].wear_represents or "mechanical_wear") ~= "technic_RE_charge" then return itemstack end
+	local temp
+	if item_load == 0 then
+		temp = 0
+	else
+		temp = 65536 - math.floor(item_load / max_load * 65535)
+		if temp > 65535 then temp = 65535 end
+		if temp < 1 then temp = 1 end
+	end
 	itemstack:set_wear(temp)
 	return itemstack
 end

--
Gitblit v1.8.0