2022-12-01 18:33:19 +01:00
|
|
|
local S = minetest.get_translator(minetest.get_current_modname())
|
|
|
|
|
2012-03-05 19:21:26 +01:00
|
|
|
-- HYDRO_TURBINE
|
2012-12-08 22:28:46 +01:00
|
|
|
-- Water turbine:
|
|
|
|
-- Active if flowing >water< above it
|
|
|
|
-- (does not work with other liquids)
|
2012-03-05 19:21:26 +01:00
|
|
|
|
|
|
|
minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", {
|
2014-11-24 00:05:01 +01:00
|
|
|
drawtype = "mesh",
|
2017-02-12 19:57:30 +01:00
|
|
|
mesh = "jeija_hydro_turbine_off.obj",
|
2015-05-20 09:40:59 +02:00
|
|
|
tiles = {
|
|
|
|
"jeija_hydro_turbine_sides_off.png",
|
|
|
|
"jeija_hydro_turbine_top_bottom.png",
|
2017-02-12 19:57:30 +01:00
|
|
|
"jeija_hydro_turbine_turbine_top_bottom_off.png",
|
|
|
|
"jeija_hydro_turbine_turbine_misc_off.png"
|
2015-05-20 09:40:59 +02:00
|
|
|
},
|
2021-04-09 20:24:41 +02:00
|
|
|
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or nil,
|
2014-11-24 00:05:01 +01:00
|
|
|
inventory_image = "jeija_hydro_turbine_inv.png",
|
2017-10-31 22:50:39 +01:00
|
|
|
is_ground_content = false,
|
2014-11-24 00:05:01 +01:00
|
|
|
wield_scale = {x=0.75, y=0.75, z=0.75},
|
2012-12-08 22:28:46 +01:00
|
|
|
groups = {dig_immediate=2},
|
2022-12-01 18:33:19 +01:00
|
|
|
description = S("Water Turbine"),
|
2012-07-20 15:26:13 +02:00
|
|
|
paramtype = "light",
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
2014-11-24 00:05:01 +01:00
|
|
|
fixed = { -0.5, -0.5, -0.5, 0.5, 1.5, 0.5 },
|
2012-07-20 15:26:13 +02:00
|
|
|
},
|
2022-05-05 16:57:53 +02:00
|
|
|
sounds = mesecon.node_sound.metal,
|
2012-12-08 22:28:46 +01:00
|
|
|
mesecons = {receptor = {
|
|
|
|
state = mesecon.state.off
|
2017-10-07 00:44:49 +02:00
|
|
|
}},
|
|
|
|
on_blast = mesecon.on_blastnode,
|
2012-03-05 19:21:26 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", {
|
2014-11-24 00:05:01 +01:00
|
|
|
drawtype = "mesh",
|
2017-10-31 22:50:39 +01:00
|
|
|
is_ground_content = false,
|
2017-02-12 19:57:30 +01:00
|
|
|
mesh = "jeija_hydro_turbine_on.obj",
|
2014-11-24 00:05:01 +01:00
|
|
|
wield_scale = {x=0.75, y=0.75, z=0.75},
|
2015-05-20 09:40:59 +02:00
|
|
|
tiles = {
|
|
|
|
"jeija_hydro_turbine_sides_on.png",
|
|
|
|
"jeija_hydro_turbine_top_bottom.png",
|
2017-02-12 19:57:30 +01:00
|
|
|
{ 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} }
|
2015-05-20 09:40:59 +02:00
|
|
|
},
|
2021-04-09 20:24:41 +02:00
|
|
|
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or nil,
|
2014-11-24 00:05:01 +01:00
|
|
|
inventory_image = "jeija_hydro_turbine_inv.png",
|
2013-04-28 12:40:08 +02:00
|
|
|
drop = "mesecons_hydroturbine:hydro_turbine_off 1",
|
2012-12-08 22:28:46 +01:00
|
|
|
groups = {dig_immediate=2,not_in_creative_inventory=1},
|
2022-12-01 18:33:19 +01:00
|
|
|
description = S("Water Turbine"),
|
2012-07-20 15:26:13 +02:00
|
|
|
paramtype = "light",
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
2014-11-24 00:05:01 +01:00
|
|
|
fixed = { -0.5, -0.5, -0.5, 0.5, 1.5, 0.5 },
|
2012-07-20 15:26:13 +02:00
|
|
|
},
|
2022-05-05 16:57:53 +02:00
|
|
|
sounds = mesecon.node_sound.metal,
|
2012-12-08 22:28:46 +01:00
|
|
|
mesecons = {receptor = {
|
|
|
|
state = mesecon.state.on
|
2017-10-07 00:44:49 +02:00
|
|
|
}},
|
|
|
|
on_blast = mesecon.on_blastnode,
|
2012-03-05 19:21:26 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
2016-12-26 05:38:44 +01:00
|
|
|
local function is_flowing_water(pos)
|
|
|
|
local name = minetest.get_node(pos).name
|
|
|
|
local is_water = minetest.get_item_group(name, "water") > 0
|
2022-06-05 11:11:47 +02:00
|
|
|
local def = minetest.registered_items[name]
|
|
|
|
return is_water and (def and def.liquidtype == "flowing")
|
2016-12-26 05:38:44 +01:00
|
|
|
end
|
|
|
|
|
2012-03-05 19:21:26 +01:00
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"mesecons_hydroturbine:hydro_turbine_off"},
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
2022-02-12 20:12:12 +01:00
|
|
|
action = function(pos)
|
2012-03-05 19:21:26 +01:00
|
|
|
local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
|
2016-12-26 05:38:44 +01:00
|
|
|
if is_flowing_water(waterpos) then
|
2016-02-14 21:00:37 +01:00
|
|
|
minetest.set_node(pos, {name="mesecons_hydroturbine:hydro_turbine_on"})
|
2014-11-22 15:42:22 +01:00
|
|
|
mesecon.receptor_on(pos)
|
2012-03-05 19:21:26 +01:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"mesecons_hydroturbine:hydro_turbine_on"},
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
2022-02-12 20:12:12 +01:00
|
|
|
action = function(pos)
|
2012-03-05 19:21:26 +01:00
|
|
|
local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
|
2016-12-26 05:38:44 +01:00
|
|
|
if not is_flowing_water(waterpos) then
|
2016-02-14 21:00:37 +01:00
|
|
|
minetest.set_node(pos, {name="mesecons_hydroturbine:hydro_turbine_off"})
|
2014-11-22 15:42:22 +01:00
|
|
|
mesecon.receptor_off(pos)
|
2012-03-05 19:21:26 +01:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2013-04-28 12:40:08 +02:00
|
|
|
output = "mesecons_hydroturbine:hydro_turbine_off 2",
|
2012-03-05 19:21:26 +01:00
|
|
|
recipe = {
|
2022-10-07 23:28:30 +02:00
|
|
|
{"","group:stick", ""},
|
2022-05-05 16:57:53 +02:00
|
|
|
{"group:stick", "mesecons_gamecompat:steel_ingot", "group:stick"},
|
|
|
|
{"","group:stick", ""},
|
2012-03-05 19:21:26 +01:00
|
|
|
}
|
|
|
|
})
|