diff options
author | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2017-02-21 12:34:08 -0500 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2017-02-21 13:36:58 -0500 |
commit | 4888581bee50a72d68feb4401c37540405f92062 (patch) | |
tree | 1bbb79238e5c6a4603db9782f62c048b3051a6dc | |
parent | 8cab1a0aec8359b14824e0d2006b05796862a962 (diff) |
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.
-rw-r--r-- | technic/machines/LV/water_mill.lua | 10 |
1 files 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) |