diff options
author | Carter Kolwey <cheapiephp@gmail.com> | 2016-12-25 22:38:44 -0600 |
---|---|---|
committer | Jeija <norrepli@gmail.com> | 2016-12-31 10:57:50 +0100 |
commit | 79edbed8d7dc3a0280b2f631b95e36a49d7c5916 (patch) | |
tree | 4f74d4f80e339e3534da4740ad57f956ffbae8df | |
parent | 8743699298dcd2bbe8096bd27dd4bb1f67ce0974 (diff) | |
download | mesecons-79edbed8d7dc3a0280b2f631b95e36a49d7c5916.tar mesecons-79edbed8d7dc3a0280b2f631b95e36a49d7c5916.tar.gz mesecons-79edbed8d7dc3a0280b2f631b95e36a49d7c5916.tar.bz2 mesecons-79edbed8d7dc3a0280b2f631b95e36a49d7c5916.tar.xz mesecons-79edbed8d7dc3a0280b2f631b95e36a49d7c5916.zip |
Allow water turbines to work with river water (fixes #294)
This also makes turbines compatible with any liquid that is in the `water` group and has `liquidtype == "flowing"`.
-rw-r--r-- | mesecons_hydroturbine/init.lua | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/mesecons_hydroturbine/init.lua b/mesecons_hydroturbine/init.lua index f1292e9..6286293 100644 --- a/mesecons_hydroturbine/init.lua +++ b/mesecons_hydroturbine/init.lua @@ -53,13 +53,20 @@ minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", { }) +local function is_flowing_water(pos) + local name = minetest.get_node(pos).name + local is_water = minetest.get_item_group(name, "water") > 0 + local is_flowing = minetest.registered_items[name].liquidtype == "flowing" + return (is_water and is_flowing) +end + minetest.register_abm({ nodenames = {"mesecons_hydroturbine:hydro_turbine_off"}, interval = 1, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) local waterpos={x=pos.x, y=pos.y+1, z=pos.z} - if minetest.get_node(waterpos).name=="default:water_flowing" then + if is_flowing_water(waterpos) then minetest.set_node(pos, {name="mesecons_hydroturbine:hydro_turbine_on"}) nodeupdate(pos) mesecon.receptor_on(pos) @@ -73,7 +80,7 @@ nodenames = {"mesecons_hydroturbine:hydro_turbine_on"}, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) local waterpos={x=pos.x, y=pos.y+1, z=pos.z} - if minetest.get_node(waterpos).name~="default:water_flowing" then + if not is_flowing_water(waterpos) then minetest.set_node(pos, {name="mesecons_hydroturbine:hydro_turbine_off"}) nodeupdate(pos) mesecon.receptor_off(pos) |