diff options
Diffstat (limited to 'mesecons_hydroturbine/init.lua')
-rw-r--r-- | mesecons_hydroturbine/init.lua | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/mesecons_hydroturbine/init.lua b/mesecons_hydroturbine/init.lua index f1292e9..409da75 100644 --- a/mesecons_hydroturbine/init.lua +++ b/mesecons_hydroturbine/init.lua @@ -5,12 +5,12 @@ minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", { drawtype = "mesh", - mesh = "jeija_hydro_turbine.obj", + mesh = "jeija_hydro_turbine_off.obj", tiles = { "jeija_hydro_turbine_sides_off.png", "jeija_hydro_turbine_top_bottom.png", - "jeija_hydro_turbine_turbine_top_bottom.png", - "jeija_hydro_turbine_turbine_misc.png" + "jeija_hydro_turbine_turbine_top_bottom_off.png", + "jeija_hydro_turbine_turbine_misc_off.png" }, inventory_image = "jeija_hydro_turbine_inv.png", wield_scale = {x=0.75, y=0.75, z=0.75}, @@ -29,13 +29,15 @@ minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", { minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", { drawtype = "mesh", - mesh = "jeija_hydro_turbine.obj", + mesh = "jeija_hydro_turbine_on.obj", wield_scale = {x=0.75, y=0.75, z=0.75}, tiles = { "jeija_hydro_turbine_sides_on.png", "jeija_hydro_turbine_top_bottom.png", - "jeija_hydro_turbine_turbine_top_bottom.png", - "jeija_hydro_turbine_turbine_misc.png" + { name = "jeija_hydro_turbine_turbine_top_bottom_on.png", + animation = {type = "vertical_frames", aspect_w = 128, aspect_h = 16, length = 1.6} }, + { name = "jeija_hydro_turbine_turbine_misc_on.png", + animation = {type = "vertical_frames", aspect_w = 256, aspect_h = 32, length = 0.4} } }, inventory_image = "jeija_hydro_turbine_inv.png", drop = "mesecons_hydroturbine:hydro_turbine_off 1", @@ -53,13 +55,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 +82,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) |