From 7cfb3874a381d5923611242b4cf7756d86049def Mon Sep 17 00:00:00 2001 From: Kevin Zheng <kevinz5000@gmail.com> Date: Wed, 06 Aug 2014 19:08:48 +0200 Subject: [PATCH] Evenly distribute charge across multiple batteries --- technic/machines/MV/wind_mill.lua | 84 ++++++++++++++++++++---------------------- 1 files changed, 40 insertions(+), 44 deletions(-) diff --git a/technic/machines/MV/wind_mill.lua b/technic/machines/MV/wind_mill.lua index 6930228..4d63ddc 100644 --- a/technic/machines/MV/wind_mill.lua +++ b/technic/machines/MV/wind_mill.lua @@ -13,9 +13,9 @@ minetest.register_craft({ output = 'technic:wind_mill', recipe = { - {'', 'technic:carbon_steel_ingot', ''}, - {'technic:carbon_steel_ingot', 'technic:motor', 'technic:carbon_steel_ingot'}, - {'', 'technic:carbon_steel_block', ''}, + {'', 'technic:motor', ''}, + {'technic:carbon_steel_ingot', 'technic:carbon_steel_block', 'technic:carbon_steel_ingot'}, + {'', 'technic:mv_cable0', ''}, } }) @@ -27,30 +27,6 @@ groups = {cracky=3}, sounds = default.node_sound_stone_defaults(), paramtype = "light", -}) - -minetest.register_node("technic:wind_mill", { - description = S("Wind Mill"), - tiles = {"technic_carbon_steel_block.png"}, - paramtype2 = "facedir", - groups = {cracky=1}, - sounds = default.node_sound_stone_defaults(), - drawtype = "nodebox", - paramtype = "light", - node_box = { - type = "fixed", - fixed = { - {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, -- Main box - {-0.1, -0.1, -0.5, 0.1, 0.1, -0.6}, -- Shaft - {-0.1, -1, -0.6, 0.1, 1, -0.7}, -- Vertical blades - {-1, -0.1, -0.6, 1, 0.1, -0.7}, -- Horizontal blades - } - }, - on_construct = function(pos) - local meta = minetest.get_meta(pos) - meta:set_string("infotext", S("Wind Mill")) - meta:set_int("MV_EU_supply", 0) - end, }) local function check_wind_mill(pos) @@ -66,25 +42,45 @@ 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 Mill") - local power = math.min(pos.y * 100, 5000) +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)") + 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, technic_machine=1}, + sounds = default.node_sound_stone_defaults(), + drawtype = "nodebox", + paramtype = "light", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, -- Main box + {-0.1, -0.1, -0.5, 0.1, 0.1, -0.6}, -- Shaft + {-0.1, -1, -0.6, 0.1, 1, -0.7}, -- Vertical blades + {-1, -0.1, -0.6, 1, 0.1, -0.7}, -- Horizontal blades + } + }, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("infotext", S("Wind %s Generator"):format("MV")) + meta:set_int("MV_EU_supply", 0) + end, + technic_run = run, }) technic.register_machine("MV", "technic:wind_mill", technic.producer) -- Gitblit v1.8.0