ethereal/water.lua

183 lines
4.6 KiB
Lua
Raw Normal View History

2016-06-09 15:08:34 +01:00
local S = ethereal.intllib
2014-11-09 19:17:41 +00:00
-- Ice Brick
minetest.register_node("ethereal:icebrick", {
2016-06-09 15:08:34 +01:00
description = S("Ice Brick"),
2014-11-09 19:17:41 +00:00
tiles = {"brick_ice.png"},
paramtype = "light",
freezemelt = "default:water_source",
2015-06-24 10:00:12 +01:00
is_ground_content = false,
groups = {cracky = 3, puts_out_fire = 1, cools_lava = 1},
2014-11-09 19:17:41 +00:00
sounds = default.node_sound_glass_defaults(),
})
minetest.register_craft({
2019-08-05 08:57:49 +01:00
output = "ethereal:icebrick 4",
2014-11-09 19:17:41 +00:00
recipe = {
2019-08-05 08:57:49 +01:00
{"default:ice", "default:ice"},
{"default:ice", "default:ice"},
2014-11-09 19:17:41 +00:00
}
})
-- Snow Brick
minetest.register_node("ethereal:snowbrick", {
2016-06-09 15:08:34 +01:00
description = S("Snow Brick"),
2014-11-09 19:17:41 +00:00
tiles = {"brick_snow.png"},
paramtype = "light",
freezemelt = "default:water_source",
2015-06-24 10:00:12 +01:00
is_ground_content = false,
groups = {crumbly = 3, puts_out_fire = 1, cools_lava = 1},
2014-11-09 19:17:41 +00:00
sounds = default.node_sound_dirt_defaults({
footstep = {name = "default_snow_footstep", gain = 0.15},
dug = {name = "default_snow_footstep", gain = 0.2},
dig = {name = "default_snow_footstep", gain = 0.2},
2014-11-09 19:17:41 +00:00
}),
})
minetest.register_craft({
2019-08-05 08:57:49 +01:00
output = "ethereal:snowbrick 4",
2014-11-09 19:17:41 +00:00
recipe = {
2019-08-05 08:57:49 +01:00
{"default:snowblock", "default:snowblock"},
{"default:snowblock", "default:snowblock"},
2014-11-09 19:17:41 +00:00
}
})
-- If Crystal Spike, Crystal Dirt, Snow near Water, change Water to Ice
minetest.register_abm({
2016-08-19 17:22:09 +01:00
label = "Ethereal freeze water",
2015-07-04 12:22:39 +01:00
nodenames = {
"ethereal:crystal_spike", "default:snow", "default:snowblock",
"ethereal:snowbrick"
},
2015-07-15 17:32:19 +01:00
neighbors = {"default:water_source", "default:river_water_source"},
2014-11-09 19:17:41 +00:00
interval = 15,
chance = 4,
2015-11-07 20:50:50 +00:00
catch_up = false,
2014-11-09 19:17:41 +00:00
action = function(pos, node)
2016-08-19 17:22:09 +01:00
local near = minetest.find_node_near(pos, 1,
2015-07-15 17:32:19 +01:00
{"default:water_source", "default:river_water_source"})
2015-11-17 20:35:10 +00:00
2016-08-19 17:22:09 +01:00
if near then
minetest.swap_node(near, {name = "default:ice"})
2014-11-09 19:17:41 +00:00
end
end,
})
-- If Heat Source near Ice or Snow then melt.
2014-11-09 19:17:41 +00:00
minetest.register_abm({
2016-08-19 17:22:09 +01:00
label = "Ethereal melt snow/ice",
2015-07-04 12:22:39 +01:00
nodenames = {
"default:ice", "default:snowblock", "default:snow",
"default:dirt_with_snow", "ethereal:snowbrick", "ethereal:icebrick"
},
neighbors = {
"fire:basic_fire", "default:lava_source", "default:lava_flowing",
"default:furnace_active", "default:torch", "default:torch_wall",
"default:torch_ceiling"
2015-07-04 12:22:39 +01:00
},
2015-04-11 10:26:30 +01:00
interval = 5,
chance = 4,
2015-11-07 20:50:50 +00:00
catch_up = false,
action = function(pos, node)
local water_node = "default:water"
if pos.y > 2 then
water_node = "default:river_water"
end
2015-07-04 12:22:39 +01:00
if node.name == "default:ice"
or node.name == "default:snowblock"
or node.name == "ethereal:icebrick"
or node.name == "ethereal:snowbrick" then
2016-01-09 12:25:33 +00:00
minetest.swap_node(pos, {name = water_node.."_source"})
2015-04-11 10:26:30 +01:00
elseif node.name == "default:snow" then
2016-01-09 12:25:33 +00:00
minetest.swap_node(pos, {name = water_node.."_flowing"})
2014-11-09 19:17:41 +00:00
elseif node.name == "default:dirt_with_snow" then
2016-01-09 12:25:33 +00:00
minetest.swap_node(pos, {name = "default:dirt_with_grass"})
2014-11-09 19:17:41 +00:00
end
ethereal.check_falling(pos)
2014-11-09 19:17:41 +00:00
end,
})
-- If Water Source near Dry Dirt, change to normal Dirt
minetest.register_abm({
2016-08-19 17:22:09 +01:00
label = "Ethereal wet dry dirt",
nodenames = {
"ethereal:dry_dirt", "default:dirt_with_dry_grass",
"default:dry_dirt", "default:dry_dirt_with_dry_grass"
},
2014-11-09 19:17:41 +00:00
neighbors = {"group:water"},
interval = 15,
chance = 2,
2015-11-07 20:50:50 +00:00
catch_up = false,
action = function(pos, node)
if node.name == "ethereal:dry_dirt"
or node.name == "default:dry_dirt" then
2016-01-09 12:25:33 +00:00
minetest.swap_node(pos, {name = "default:dirt"})
else
minetest.swap_node(pos, {name = "default:dirt_with_dry_grass"})
end
2014-11-09 19:17:41 +00:00
end,
})
2014-12-29 11:03:11 +00:00
-- If torch touching water then drop as item (when enabled)
if ethereal.torchdrop == true then
2017-02-28 15:28:36 +00:00
local torch_drop = "default:torch"
local drop_sound = "fire_extinguish_flame"
2017-02-28 15:28:36 +00:00
if minetest.get_modpath("real_torch") then
torch_drop = "real_torch:torch"
drop_sound = "real_torch_extinguish"
2017-02-28 15:28:36 +00:00
end
2015-03-01 11:20:12 +00:00
minetest.register_abm({
2016-08-19 17:22:09 +01:00
label = "Ethereal drop torch",
2017-02-28 15:28:36 +00:00
nodenames = {"default:torch", "default:torch_wall", "default:torch_ceiling",
"real_torch:torch", "real_torch:torch_wall", "real_torch:torch_ceiling"},
2015-04-11 10:26:30 +01:00
neighbors = {"group:water"},
interval = 5,
2015-03-01 11:20:12 +00:00
chance = 1,
2015-11-07 20:50:50 +00:00
catch_up = false,
2015-03-01 11:20:12 +00:00
action = function(pos, node)
2015-07-04 12:22:39 +01:00
local num = #minetest.find_nodes_in_area(
{x = pos.x - 1, y = pos.y, z = pos.z},
{x = pos.x + 1, y = pos.y, z = pos.z},
{"group:water"})
if num == 0 then
num = num + #minetest.find_nodes_in_area(
{x = pos.x, y = pos.y, z = pos.z - 1},
{x = pos.x, y = pos.y, z = pos.z + 1},
{"group:water"})
end
if num == 0 then
num = num + #minetest.find_nodes_in_area(
{x = pos.x, y = pos.y + 1, z = pos.z},
{x = pos.x, y = pos.y + 1, z = pos.z},
{"group:water"})
end
2015-04-11 10:26:30 +01:00
if num > 0 then
2016-12-10 15:25:28 +00:00
minetest.set_node(pos, {name = "air"})
minetest.sound_play({name = drop_sound, gain = 0.2},
{pos = pos, max_hear_distance = 10})
2017-02-28 15:28:36 +00:00
minetest.add_item(pos, {name = torch_drop})
2015-03-01 11:20:12 +00:00
end
end,
2016-01-09 12:25:33 +00:00
})
end