From 636b0f20df4fef3eef821c23ccc2f606828f5c6f Mon Sep 17 00:00:00 2001
From: Zefram <zefram@fysh.org>
Date: Mon, 07 Jul 2014 15:15:05 +0200
Subject: [PATCH] Handheld prospecting tool

---
 technic/machines/MV/tool_workshop.lua |   38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/technic/machines/MV/tool_workshop.lua b/technic/machines/MV/tool_workshop.lua
index 046fef1..15aa09d 100644
--- a/technic/machines/MV/tool_workshop.lua
+++ b/technic/machines/MV/tool_workshop.lua
@@ -17,32 +17,25 @@
 local workshop_formspec =
 	"invsize[8,9;]"..
 	"list[current_name;src;3,1;1,1;]"..
-	"label[0,0;"..S("Tool Workshop").."]"..
+	"label[0,0;"..S("%s Tool Workshop"):format("MV").."]"..
 	"list[current_player;main;0,5;8,4;]"
 
 minetest.register_node("technic:tool_workshop", {
-	description = S("Tool Workshop"),
+	description = S("%s Tool Workshop"):format("MV"),
 	tiles = {"technic_workshop_top.png", "technic_machine_bottom.png", "technic_workshop_side.png",
 	         "technic_workshop_side.png", "technic_workshop_side.png", "technic_workshop_side.png"},
 	groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
 	sounds = default.node_sound_wood_defaults(),
 	on_construct = function(pos)
 		local meta = minetest.get_meta(pos)
-		meta:set_string("infotext", S("Tool Workshop"))
+		meta:set_string("infotext", S("%s Tool Workshop"):format("MV"))
 		meta:set_string("formspec", workshop_formspec)
 		local inv = meta:get_inventory()
 		inv:set_size("src", 1)
 	end,	
-	can_dig = function(pos,player)
-		local meta = minetest.get_meta(pos);
-		local inv = meta:get_inventory()
-		if not inv:is_empty("src") then
-			minetest.chat_send_player(player:get_player_name(),
-				S("Machine cannot be removed because it is not empty"))
-			return false
-		end
-		return true
-	end,
+	can_dig = technic.machine_can_dig,
+	allow_metadata_inventory_put = technic.machine_inventory_put,
+	allow_metadata_inventory_take = technic.machine_inventory_take,
 })
 
 minetest.register_abm({
@@ -53,7 +46,7 @@
 		local meta         = minetest.get_meta(pos)
 		local inv          = meta:get_inventory()
 		local eu_input     = meta:get_int("MV_EU_input")
-		local machine_name = S("Tool Workshop")
+		local machine_name = S("%s Tool Workshop"):format("MV")
 		local machine_node = "technic:tool_workshop"
 		local demand       = 5000
 
@@ -67,11 +60,18 @@
 		-- Power off automatically if no longer connected to a switching station
 		technic.switching_station_timeout_count(pos, "MV")
 
-		srcstack = inv:get_stack("src", 1)
-		if inv:is_empty("src") or
-		   srcstack:get_wear() == 0 or
-		   srcstack:get_name() == "technic:water_can" or
-		   srcstack:get_name() == "technic:lava_can" then
+		local repairable = false
+		local srcstack = inv:get_stack("src", 1)
+		if not srcstack:is_empty() then
+			local itemdef = minetest.registered_items[srcstack:get_name()]
+			if itemdef and
+					(not itemdef.wear_represents or
+					itemdef.wear_represents == "mechanical_wear") and
+					srcstack:get_wear() ~= 0 then
+				repairable = true
+			end
+		end
+		if not repairable then
 			meta:set_string("infotext", S("%s Idle"):format(machine_name))
 			meta:set_int("MV_EU_demand", 0)
 			return

--
Gitblit v1.8.0