From b81d1d3f2debcab4d18cf4dee824075ef0bbb116 Mon Sep 17 00:00:00 2001
From: Lejo <Lejo_1@web.de>
Date: Sat, 13 Apr 2019 20:45:49 +0200
Subject: [PATCH] Check protection of the forcefield and Quarry (#468)

---
 technic/machines/MV/power_radiator.lua |   36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/technic/machines/MV/power_radiator.lua b/technic/machines/MV/power_radiator.lua
index 2617578..623af34 100644
--- a/technic/machines/MV/power_radiator.lua
+++ b/technic/machines/MV/power_radiator.lua
@@ -12,6 +12,16 @@
 
 local power_radius = 12
 
+
+minetest.register_craft({
+	output = 'technic:power_radiator 1',
+	recipe = {
+		{'technic:stainless_steel_ingot', 'technic:mv_transformer', 'technic:stainless_steel_ingot'},
+		{'technic:copper_coil',           'technic:machine_casing', 'technic:copper_coil'},
+		{'technic:rubber',                'technic:mv_cable',       'technic:rubber'},
+	}
+})
+
 ------------------------------------------------------------------
 -- API for inductive powered nodes:
 -- Use the functions below to set the corresponding callbacks
@@ -43,7 +53,7 @@
 technic.inductive_on_punch_off = function(pos, eu_charge, swapnode)
 	local meta = minetest.get_meta(pos)
 	if meta:get_string("has_supply") ~= "" then
-		hacky_swap_node(pos, swapnode)
+		technic.swap_node(pos, swapnode)
 		meta:set_int("active", 1)
 		meta:set_int("EU_charge",eu_charge)
 		--print("-----------")
@@ -56,7 +66,7 @@
 
 technic.inductive_on_punch_on = function(pos, eu_charge, swapnode)
 	local meta = minetest.get_meta(pos)
-	hacky_swap_node(pos, swapnode)
+	technic.swap_node(pos, swapnode)
 	meta:set_int("active", 0)
 	meta:set_int("EU_charge",eu_charge)
 	--print("-----------")
@@ -82,7 +92,7 @@
 			local nodename = minetest.get_node(pos1).name
 			-- Swap the node and make sure it is off and unpowered
 			if string.sub(nodename, -7) == "_active" then
-				hacky_swap_node(pos1, string.sub(nodename, 1, -8))
+				technic.swap_node(pos1, string.sub(nodename, 1, -8))
 				meta1:set_int("active", 0)
 				meta1:set_int("EU_charge", 0)
 			end
@@ -108,7 +118,7 @@
 end
 
 minetest.register_node("technic:power_radiator", {
-	description = "Power Radiator",
+	description = "MV Power Radiator",
 	tiles  = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
 	          "technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"},
 	groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
@@ -124,7 +134,7 @@
 		local meta = minetest.get_meta(pos)
 		meta:set_int("MV_EU_demand",1)               -- Demand on the primary side when idle
 		meta:set_int("connected_EU_demand",0)        -- Potential demand of connected appliances
-		meta:set_string("infotext", "Power Radiator")
+		meta:set_string("infotext", "MV Power Radiator")
 	end,
 	on_dig = function(pos, node, digger)
 		shutdown_inductive_appliances(pos)
@@ -135,21 +145,13 @@
 	end
 })
 
-minetest.register_craft({
-	output = 'technic:power_radiator 1',
-	recipe = {
-		{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
-		{'technic:copper_coil',           'technic:mv_transformer',        'technic:copper_coil'},
-		{'technic:rubber',                'technic:mv_cable0',       'technic:rubber'},
-	}
-})
-
 minetest.register_abm({
+	label = "Machines: run power radiator",
 	nodenames = {"technic:power_radiator"},
 	interval   = 1,
 	chance     = 1,
 	action = function(pos, node, active_object_count, active_object_count_wider)
-		local meta             = minetest.env:get_meta(pos)
+		local meta             = minetest.get_meta(pos)
 		local eu_input  = meta:get_int("MV_EU_input")
 		local eu_demand = meta:get_int("MV_EU_demand")
 
@@ -158,7 +160,7 @@
 
 		if eu_input == 0 then
 			-- No power
-			meta:set_string("infotext", "Power Radiator is unpowered");
+			meta:set_string("infotext", "MV Power Radiator is unpowered");
 			-- meta:set_int("active", 1) -- used for setting textures someday maybe
 			shutdown_inductive_appliances(pos)
 			meta:set_int("connected_EU_demand", 0)
@@ -201,7 +203,7 @@
 					-- The appliance has power from this node. Spend power if it is on.
 					used_charge = used_charge + math.floor(meta1:get_int("EU_charge") / eff_factor)
 				end
-				meta:set_string("infotext", "Power Radiator is powered ("
+				meta:set_string("infotext", "MV Power Radiator is powered ("
 					..math.floor(used_charge / max_charge * 100)
 					.."% of maximum power)");
 				if used_charge == 0 then

--
Gitblit v1.8.0