1
- if not minetest . get_modpath ( " default " ) then return end
1
+ dynamic_liquid . cooling_lava = function ( def )
2
2
3
- local new_lava_cooling = minetest .settings :get_bool (" dynamic_liquid_new_lava_cooling" , true )
4
- if not new_lava_cooling then return end
3
+ local lava_source = def .lava_source
4
+ local lava_flowing = def .lava_flowing
5
+ local obsidian = def .obsidian
6
+ local flowing_destroys = def .flowing_destroys or {}
7
+ local source_destroys = def .source_destroys or {}
8
+ local cooling_sound = def .cooling_sound
9
+
10
+ local falling_obsidian = dynamic_liquid .config .falling_obsidian
5
11
6
- local falling_obsidian = minetest .settings :get_bool (" dynamic_liquid_falling_obsidian" , false )
7
12
8
13
-- The existing cool_lava ABM is hard-coded to respond to water nodes
9
14
-- and overriding node groups doesn't appear to work:
@@ -20,7 +25,6 @@ local falling_obsidian = minetest.settings:get_bool("dynamic_liquid_falling_obsi
20
25
-- to nodes that should be destroyed by proximity to lava.
21
26
22
27
local particles = minetest .settings :get_bool (" enable_particles" , true )
23
-
24
28
local steam = function (pos )
25
29
if particles then
26
30
minetest .add_particlespawner ({
@@ -43,22 +47,19 @@ local steam = function(pos)
43
47
end
44
48
end
45
49
46
- default .cool_lava = function (pos , node )
47
- -- no-op disables default cooling ABM
48
- end
49
50
50
51
---- ---------------------------------------------------------------------------------------------
51
52
53
+
52
54
local dynamic_cools_lava_flowing = {" group:dynamic_cools_lava_flowing" , " group:cools_lava" }
53
55
54
56
-- Flowing lava will turn these blocks into steam.
55
57
local dynamic_lava_flowing_destroys = {
56
58
" group:dynamic_lava_flowing_destroys" ,
57
- " default:water_flowing" ,
58
- " default:river_water_flowing" ,
59
- " default:snow" ,
60
- " default:snowblock"
61
59
}
60
+ for _ , node_name in pairs (flowing_destroys ) do
61
+ table.insert (dynamic_lava_flowing_destroys , node_name )
62
+ end
62
63
63
64
local all_flowing_nodes = {unpack (dynamic_cools_lava_flowing )}
64
65
for i = 1 , # dynamic_lava_flowing_destroys do
@@ -71,9 +72,9 @@ local cool_lava_flowing = function(pos, node)
71
72
if cooler_adjacent ~= nil then
72
73
-- pulling nearby sources into position is necessary to break certain classes of
73
74
-- flow "deadlock". Weird, but what're you gonna do.
74
- local nearby_source = minetest .find_node_near (pos , 1 , " default: lava_source" )
75
+ local nearby_source = minetest .find_node_near (pos , 1 , lava_source )
75
76
if nearby_source then
76
- minetest .set_node (pos , {name = " default: lava_source" })
77
+ minetest .set_node (pos , {name = lava_source })
77
78
minetest .set_node (nearby_source , {name = " air" })
78
79
steam (nearby_source )
79
80
else
@@ -92,13 +93,13 @@ local cool_lava_flowing = function(pos, node)
92
93
steam (loc )
93
94
end
94
95
95
- minetest .sound_play (" default_cool_lava " ,
96
+ minetest .sound_play (cooling_sound ,
96
97
{pos = pos , max_hear_distance = 16 , gain = 0.25 })
97
98
end
98
99
99
100
minetest .register_abm ({
100
101
label = " Lava flowing cooling" ,
101
- nodenames = {" default: lava_flowing" },
102
+ nodenames = {lava_flowing },
102
103
neighbors = all_flowing_nodes ,
103
104
interval = 1 ,
104
105
chance = 1 ,
@@ -122,14 +123,11 @@ end
122
123
-- lava source blocks will turn these blocks into steam.
123
124
local dynamic_lava_source_destroys = {
124
125
" group:dynamic_lava_source_destroys" ,
125
- " default:water_source" ,
126
- " default:river_water_source" ,
127
- " default:water_flowing" ,
128
- " default:river_water_flowing" ,
129
- " default:ice" ,
130
- " default:snow" ,
131
- " default:snowblock"
132
126
}
127
+ for _ , node_name in pairs (source_destroys ) do
128
+ table.insert (dynamic_lava_source_destroys , node_name )
129
+ end
130
+
133
131
134
132
local all_source_nodes = {unpack (dynamic_cools_lava_source )}
135
133
for i = 1 , # dynamic_lava_source_destroys do
@@ -193,32 +191,35 @@ local cool_lava_source = function(pos, node)
193
191
194
192
if obsidian_location ~= nil then
195
193
minetest .set_node (pos , {name = " air" })
196
- minetest .set_node (obsidian_location , {name = " default: obsidian" })
197
- if minetest . spawn_falling_node and falling_obsidian then -- TODO cutting-edge dev function, so check if it exists for the time being. Remove check when 0.4.16 is released.
194
+ minetest .set_node (obsidian_location , {name = obsidian })
195
+ if falling_obsidian then
198
196
minetest .spawn_falling_node (obsidian_location )
199
197
end
200
198
elseif # evaporate_list > 0 then
201
199
-- Again, this weird bit is necessary for breaking certain types of flow deadlock
202
200
local loc = evaporate_list [math.random (1 ,# evaporate_list )]
203
201
if loc .y <= pos .y then
204
202
minetest .set_node (pos , {name = " air" })
205
- minetest .set_node (loc , {name = " default: lava_source" })
203
+ minetest .set_node (loc , {name = lava_source })
206
204
end
207
205
end
208
206
209
- minetest .sound_play (" default_cool_lava " ,
207
+ minetest .sound_play (cooling_sound ,
210
208
{pos = pos , max_hear_distance = 16 , gain = 0.25 })
211
209
end
212
210
213
211
214
212
minetest .register_abm ({
215
213
label = " Lava source cooling" ,
216
- nodenames = {" default: lava_source" },
214
+ nodenames = {lava_source },
217
215
neighbors = all_source_nodes ,
218
216
interval = 1 ,
219
217
chance = 1 ,
220
218
catch_up = false ,
221
219
action = function (...)
222
220
cool_lava_source (... )
223
221
end ,
224
- })
222
+ })
223
+
224
+
225
+ end
0 commit comments