From 9087abcde029b12a8d21f90bf71fdf85ecff7d86 Mon Sep 17 00:00:00 2001 From: Tim <t4im@users.noreply.github.com> Date: Fri, 30 Jan 2015 05:09:21 +0100 Subject: [PATCH] add centrifuge recipe for wheat --- technic/machines/MV/wind_mill.lua | 68 ++++++++++++++++------------------ 1 files changed, 32 insertions(+), 36 deletions(-) diff --git a/technic/machines/MV/wind_mill.lua b/technic/machines/MV/wind_mill.lua index 1bc8e02..4d63ddc 100644 --- a/technic/machines/MV/wind_mill.lua +++ b/technic/machines/MV/wind_mill.lua @@ -29,11 +29,40 @@ paramtype = "light", }) +local function check_wind_mill(pos) + if pos.y < 30 then + return false + end + for i = 1, 20 do + local node = minetest.get_node({x=pos.x, y=pos.y-i, z=pos.z}) + if node.name ~= "technic:wind_mill_frame" then + return false + end + end + return true +end + +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 + meta:set_int("MV_EU_supply", 0) + meta:set_string("infotext", S("%s Improperly Placed"):format(machine_name)) + return + else + meta:set_int("MV_EU_supply", power) + end + + meta:set_string("infotext", machine_name.." ("..power.."EU)") +end + minetest.register_node("technic:wind_mill", { description = S("Wind %s Generator"):format("MV"), tiles = {"technic_carbon_steel_block.png"}, paramtype2 = "facedir", - groups = {cracky=1}, + groups = {cracky=1, technic_machine=1}, sounds = default.node_sound_stone_defaults(), drawtype = "nodebox", paramtype = "light", @@ -50,41 +79,8 @@ local meta = minetest.get_meta(pos) meta:set_string("infotext", S("Wind %s Generator"):format("MV")) meta:set_int("MV_EU_supply", 0) - end, -}) - -local function check_wind_mill(pos) - if pos.y < 30 then - return false - end - for i = 1, 20 do - local node = minetest.get_node({x=pos.x, y=pos.y-i, z=pos.z}) - if node.name ~= "technic:wind_mill_frame" then - return false - end - end - return true -end - -minetest.register_abm({ - nodenames = {"technic:wind_mill"}, - interval = 1, - chance = 1, - action = function(pos, node, active_object_count, active_object_count_wider) - 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 - meta:set_int("MV_EU_supply", 0) - meta:set_string("infotext", S("%s Improperly Placed"):format(machine_name)) - return - else - meta:set_int("MV_EU_supply", power) - end - - meta:set_string("infotext", machine_name.." ("..power.."EU)") - end + end, + technic_run = run, }) technic.register_machine("MV", "technic:wind_mill", technic.producer) -- Gitblit v1.8.0