summaryrefslogtreecommitdiff
path: root/water.lua
blob: 24a8718054477214a6fc293851c5b0cf048bca3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
-- Ice Brick
minetest.register_node("ethereal:icebrick", {
	description = "Ice Brick",
	tiles = {"brick_ice.png"},
	paramtype = "light",
	freezemelt = "default:water_source",
	groups = {cracky=3, melts=1},
	sounds = default.node_sound_glass_defaults(),
})

minetest.register_craft({
	output = 'ethereal:icebrick 4',
	recipe = {
		{'default:ice', 'default:ice'},
		{'default:ice', 'default:ice'},
	}
})

-- Snow Brick
minetest.register_node("ethereal:snowbrick", {
	description = "Snow Brick",
	tiles = {"brick_snow.png"},
	paramtype = "light",
--	leveled = 7,
	drawtype = "nodebox",
	freezemelt = "default:water_source",
	groups = {crumbly=3, melts=1},
	sounds = default.node_sound_dirt_defaults({
		footstep = {name="default_snow_footstep", gain=0.25},
		dug = {name="default_snow_footstep", gain=0.75},
	}),
	on_construct = function(pos)
		pos.y = pos.y - 1
		if minetest.get_node(pos).name == "default:dirt_with_grass" then
			minetest.set_node(pos, {name="default:dirt_with_snow"})
		end
	end,
})

minetest.register_craft({
	output = 'ethereal:snowbrick 4',
	recipe = {
		{'default:snowblock', 'default:snowblock'},
		{'default:snowblock', 'default:snowblock'},
	}
})

-- Over time Cobble placed in water changes to Mossy Cobble
minetest.register_abm({
	nodenames = {"default:cobble"},
	neighbors={"default:water_source"},
	interval = 30,
	chance = 10,
	action = function(pos, node)
	        minetest.add_node(pos, {name="default:mossycobble"})
	end
})

-- If Crystal Spike, Crystal Dirt, Snow near Water, change Water to Ice
minetest.register_abm({
	nodenames = {"ethereal:crystal_spike", "ethereal:crystal_dirt", "default:snow", "default:snowblock", "ethereal:snowbrick"},
	neighbors = {"default:water_source"},
	interval = 15,
	chance = 2,
	action = function(pos, node)
		local pos0 = {x=pos.x-1,y=pos.y-1,z=pos.z-1}
		local pos1 = {x=pos.x+1,y=pos.y+1,z=pos.z+1}

		local water = minetest.env:find_nodes_in_area(pos0, pos1, "default:water_source")
		if water then
			minetest.env:set_node(water[1], {name="default:ice"})
		end
	end,
})

-- If Heat Source near Ice or Snow then melt
minetest.register_abm({
	nodenames = {"default:ice", "default:snowblock", "default:snow", "default:dirt_with_snow", "ethereal:snowbrick", "ethereal:icebrick"},
	--nodenames = {"group:melts", "default:dirt_with_snow"},
	--neighbors = {"group:hot"},
	neighbors = {"fire:basic_fire", "default:lava_source", "default:lava_flowing", "default:furnace_active", "default:torch"},
	interval = 1, -- 10
	chance = 2,
	action = function(pos, node, active_object_count, active_object_count_wider)

		--print ("NODE:", string.split(node.name, ":")[1])

		if node.name == "default:ice" or node.name == "default:snowblock" 
		or node.name == "ethereal:icebrick" or node.name == "ethereal:snowbrick" then
			minetest.add_node(pos,{name="default:water_source"})
		elseif node.name == "default:snow" then -- or string.split(node.name, ":")[1]then
			minetest.add_node(pos,{name="default:water_flowing"})
		elseif node.name == "default:dirt_with_snow" then
			minetest.add_node(pos,{name="default:dirt_with_grass"})
		end
		nodeupdate(pos)
	end,
})

-- If Water Source near Dry Dirt, change to normal Dirt
minetest.register_abm({
	nodenames = {"ethereal:dry_dirt"},
	neighbors = {"group:water"},
	interval = 15,
	chance = 2,
	action = function(pos, node, active_object_count, active_object_count_wider)
		minetest.add_node(pos,{name="default:dirt"})
	end,
})
--[[
-- If water next to mushroom pore then remove water
minetest.register_abm({
	nodenames = {"ethereal:mushroom_pore"},
	neighbors = {"group:water"},
	interval = 2,
	chance = 1,
	action = function(pos, node)
		local pos0 = {x=pos.x-1,y=pos.y-1,z=pos.z-1}
		local pos1 = {x=pos.x+1,y=pos.y+1,z=pos.z+1}

		local water = minetest.env:find_nodes_in_area(pos0, pos1, "group:water")
		if water then
			for n = 1, #water do
				minetest.env:set_node(water[n], {name="air"})
			end
		end
	end,
})
]]