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/machines/MV/wind_mill.lua |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/technic/machines/MV/wind_mill.lua b/technic/machines/MV/wind_mill.lua
index 40ecdd6..1baf54c 100644
--- a/technic/machines/MV/wind_mill.lua
+++ b/technic/machines/MV/wind_mill.lua
@@ -13,7 +13,7 @@
 minetest.register_craft({
 	output = 'technic:wind_mill',
 	recipe = {
-		{'',                           'technic:motor',              ''},
+		{'',                           'basic_materials:motor',              ''},
 		{'technic:carbon_steel_ingot', 'technic:carbon_steel_block', 'technic:carbon_steel_ingot'},
 		{'',                           'technic:mv_cable',           ''},
 	}
@@ -33,8 +33,15 @@
 	if pos.y < 30 then
 		return false
 	end
+	pos = {x=pos.x, y=pos.y, z=pos.z}
 	for i = 1, 20 do
-		local node = minetest.get_node({x=pos.x, y=pos.y-i, z=pos.z})
+		pos.y = pos.y - 1
+		local node = minetest.get_node_or_nil(pos)
+		if not node then
+			-- we reached CONTENT_IGNORE, we can assume, that nothing changed
+			-- as the user will have to load the block to change it
+			return
+		end
 		if node.name ~= "technic:wind_mill_frame" then
 			return false
 		end
@@ -45,17 +52,18 @@
 local run = function(pos, node)
 	local meta = minetest.get_meta(pos)
 	local machine_name = S("Wind %s Generator"):format("MV")
-	local power = math.min(pos.y * 100, 5000)
 
-	if not check_wind_mill(pos) then
+	local check = check_wind_mill(pos)
+	if check == false then
 		meta:set_int("MV_EU_supply", 0)
 		meta:set_string("infotext", S("%s Improperly Placed"):format(machine_name))
-		return
-	else
+	elseif check == true then
+		local power = math.min(pos.y * 100, 5000)
 		meta:set_int("MV_EU_supply", power)
+		meta:set_string("infotext", S("@1 (@2)", machine_name,
+			technic.EU_string(power)))
 	end
-
-	meta:set_string("infotext", S("@1 (@2 EU)", machine_name, technic.prettynum(power)))
+	-- check == nil: assume nothing has changed
 end
 
 minetest.register_node("technic:wind_mill", {

--
Gitblit v1.8.0