From 5940f5bda421add111a881b4df82b793121738a9 Mon Sep 17 00:00:00 2001
From: kpoppel <poulsen.kim@gmail.com>
Date: Wed, 08 May 2013 00:06:54 +0200
Subject: [PATCH] Slope box fixes. From Bas080.

---
 technic/grinder.lua |   65 +++++++++++++++++++++-----------
 1 files changed, 43 insertions(+), 22 deletions(-)

diff --git a/technic/grinder.lua b/technic/grinder.lua
index c945928..b4dbd90 100644
--- a/technic/grinder.lua
+++ b/technic/grinder.lua
@@ -7,11 +7,12 @@
 grinder_recipes[registered_grinder_recipes_count].src_name=string1
 grinder_recipes[registered_grinder_recipes_count].dst_name=string2
 registered_grinder_recipes_count=registered_grinder_recipes_count+1
-if UI_recipes_hook then
-	minetest.register_craft({
+if unified_inventory then
+	unified_inventory.register_craft({
 	type = "grinding",
 	output = string2,
-	recipe = string1,
+	items = {string1},
+	width = 0,
 	})
 	end
 end
@@ -22,10 +23,10 @@
 register_grinder_recipe("default:desert_stone","default:desert_sand")
 register_grinder_recipe("default:iron_lump","technic:iron_dust 2") 
 register_grinder_recipe("default:coal_lump","technic:coal_dust 2") 
-register_grinder_recipe("moreores:copper_lump","technic:copper_dust 2")
+register_grinder_recipe("default:copper_lump","technic:copper_dust 2")
 register_grinder_recipe("moreores:tin_lump","technic:tin_dust 2") 
 register_grinder_recipe("moreores:silver_lump","technic:silver_dust 2")
-register_grinder_recipe("moreores:gold_lump","technic:gold_dust 2") 
+register_grinder_recipe("default:gold_lump","technic:gold_dust 2") 
 register_grinder_recipe("moreores:mithril_lump","technic:mithril_dust 2") 
 register_grinder_recipe("technic:chromium_lump","technic:chromium_dust 2") 
 register_grinder_recipe("technic:zinc_lump","technic:zinc_dust 2") 
@@ -172,7 +173,7 @@
 	output = 'technic:grinder',
 	recipe = {
 		{'default:desert_stone', 'default:desert_stone', 'default:desert_stone'},
-		{'default:desert_stone', 'technic:diamond', 'default:desert_stone'},
+		{'default:desert_stone', 'default:diamond', 'default:desert_stone'},
 		{'default:stone', 'moreores:copper_ingot', 'default:stone'},
 	}
 })
@@ -197,7 +198,7 @@
 	tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
 		"technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front.png"},
 	paramtype2 = "facedir",
-	groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+	groups = {cracky=2},
 	legacy_facedir_simple = true,
 	sounds = default.node_sound_wood_defaults(),
 	technic_power_machine=1,
@@ -214,11 +215,9 @@
 		meta:set_float("internal_EU_buffer_size", 5000)
 		meta:set_string("formspec", grinder_formspec)
 		meta:set_float("grind_time", 0)
-		
 		local inv = meta:get_inventory()
 		inv:set_size("src", 1)
 		inv:set_size("dst", 4)
-		
 		end,
 	can_dig = function(pos,player)
 		local meta = minetest.env:get_meta(pos);
@@ -229,14 +228,33 @@
 		if not inv:is_empty("dst") then
 			return false
 		end
-
 		return true
 		end,
+})
 
+minetest.register_node("technic:grinder_active", {
+	description = "Grinder",
+	tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
+		"technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front_active.png"},
+	paramtype2 = "facedir",
+	groups = {cracky=2,not_in_creative_inventory=1},
+	legacy_facedir_simple = true,
+	sounds = default.node_sound_wood_defaults(),
+	can_dig = function(pos,player)
+		local meta = minetest.env:get_meta(pos);
+		local inv = meta:get_inventory()
+		if not inv:is_empty("src") then
+			return false
+		end
+		if not inv:is_empty("dst") then
+			return false
+		end
+		return true
+		end,
 })
 
 minetest.register_abm({
-	nodenames = {"technic:grinder"},
+	nodenames = {"technic:grinder","technic:grinder_active"},
 	interval = 1,
 	chance = 1,
 	action = function(pos, node, active_object_count, active_object_count_wider)
@@ -258,12 +276,7 @@
 				"list[current_player;main;0,5;8,4;]"
 				)
 
-		
-
 		local inv = meta:get_inventory()
-		
---		local grinder_on = meta:get_float("grinder_on")
-		
 		local srclist = inv:get_list("src")
 		if inv:is_empty("src") then meta:set_float("grinder_on",0) end 
 
@@ -293,12 +306,19 @@
 		if (meta:get_float("grinder_on")==0) then
 		local grinded=nil 
 		if not inv:is_empty("src") then
-		 grinded = get_grinded_item (inv:get_stack("src", 1))
-		 if grinded then meta:set_float("grinder_on",1) end
-		 grind_time=4
-		 meta:set_float("grind_time",grind_time)
-		 meta:set_float("src_time", 0)
-		 return
+			grinded = get_grinded_item (inv:get_stack("src", 1))
+			if grinded then 
+				meta:set_float("grinder_on",1)
+				hacky_swap_node(pos,"technic:grinder_active")
+				meta:set_string("infotext", "Grinder Active")
+				grind_time=4
+				meta:set_float("grind_time",grind_time)
+				meta:set_float("src_time", 0)
+				return
+			end
+			else 
+				hacky_swap_node(pos,"technic:grinder")
+				meta:set_string("infotext", "Grinder Inactive")
 		end
 		end
 	end
@@ -317,3 +337,4 @@
 end
 
 register_LV_machine ("technic:grinder","RE")
+register_LV_machine ("technic:grinder_active","RE")

--
Gitblit v1.8.0