From 4888581bee50a72d68feb4401c37540405f92062 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Tue, 21 Feb 2017 12:34:08 -0500 Subject: [PATCH] Make hydro generators sense the water flow volume around them Water flow around a gen is shown more or less directly by the water's param2, range 0 to 15, so four sides could total 60. Cap the result to 45 so that three sides' worth of full flow (or four sides at reduced flow) still registers as "100%", and raise the maximum outpu to 2250 EU. --- technic/machines/LV/water_mill.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/technic/machines/LV/water_mill.lua b/technic/machines/LV/water_mill.lua index c80707f..ad461fb 100644 --- a/technic/machines/LV/water_mill.lua +++ b/technic/machines/LV/water_mill.lua @@ -26,10 +26,12 @@ end local run = function(pos, node) local meta = minetest.get_meta(pos) - local water_nodes = 0 + local water_flow = 0 local lava_nodes = 0 local production_level = 0 local eu_supply = 0 + local max_output = 50 * 45 -- four param2's at 15 makes 60, cap it lower for "overload protection" + -- (plus we want the gen to report 100% if three sides have full flow) local positions = { {x=pos.x+1, y=pos.y, z=pos.z}, @@ -41,12 +43,12 @@ local run = function(pos, node) for _, p in pairs(positions) do local check = check_node_around_mill(p) if check then - water_nodes = water_nodes + 1 + water_flow = water_flow + check end end - production_level = 25 * water_nodes - eu_supply = 30 * water_nodes + eu_supply = 50 * water_flow + production_level = math.floor(100 * eu_supply / max_output) if production_level > 0 then meta:set_int("LV_EU_supply", eu_supply)