@@ -16,11 +16,13 @@ minetest.register_node("fire:basic_flame", {
16
16
aspect_w = 16 , aspect_h = 16 , length = 1 },
17
17
}},
18
18
inventory_image = " fire_basic_flame.png" ,
19
+ paramtype = " light" ,
19
20
light_source = 14 ,
20
21
groups = {igniter = 2 , dig_immediate = 3 },
21
22
drop = ' ' ,
22
23
walkable = false ,
23
24
buildable_to = true ,
25
+ sunlight_propagates = true ,
24
26
damage_per_second = 4 ,
25
27
26
28
on_construct = function (pos )
@@ -31,21 +33,13 @@ minetest.register_node("fire:basic_flame", {
31
33
minetest .after (0 , fire .on_flame_remove_at , pos )
32
34
end ,
33
35
34
- -- unaffected by explosions
35
- on_blast = function () end ,
36
+ on_blast = function () end , -- unaffected by explosions
36
37
})
37
38
38
39
39
- -- Fire sounds table
40
- -- key: position hash of low corner of area
41
- -- value: {handle=sound handle, name=sound name}
42
- fire .sounds = {}
43
-
44
-
45
40
-- Get sound area of position
46
41
47
- -- size of sound areas
48
- fire .D = 6
42
+ fire .D = 6 -- size of sound areas
49
43
50
44
function fire .get_area_p0p1 (pos )
51
45
local p0 = {
@@ -62,6 +56,12 @@ function fire.get_area_p0p1(pos)
62
56
end
63
57
64
58
59
+ -- Fire sounds table
60
+ -- key: position hash of low corner of area
61
+ -- value: {handle=sound handle, name=sound name}
62
+ fire .sounds = {}
63
+
64
+
65
65
-- Update fire sounds in sound area of position
66
66
67
67
function fire .update_sounds_around (pos )
@@ -73,9 +73,9 @@ function fire.update_sounds_around(pos)
73
73
local should_have_sound = (# flames_p > 0 )
74
74
local wanted_sound = nil
75
75
if # flames_p >= 9 then
76
- wanted_sound = {name = " fire_large" , gain = 1.5 }
76
+ wanted_sound = {name = " fire_large" , gain = 0.7 }
77
77
elseif # flames_p > 0 then
78
- wanted_sound = {name = " fire_small" , gain = 1.5 }
78
+ wanted_sound = {name = " fire_small" , gain = 0.9 }
79
79
end
80
80
local p0_hash = minetest .hash_node_position (p0 )
81
81
local sound = fire .sounds [p0_hash ]
@@ -125,33 +125,84 @@ end
125
125
-- Detect nearby extinguishing nodes
126
126
127
127
function fire .flame_should_extinguish (pos )
128
- if minetest .setting_getbool (" disable_fire" ) then return true end
129
- -- return minetest.find_node_near(pos, 1, {"group:puts_out_fire"})
130
- local p0 = {x = pos .x - 1 , y = pos .y , z = pos .z - 1 }
131
- local p1 = {x = pos .x + 1 , y = pos .y + 1 , z = pos .z + 1 }
132
- local ps = minetest .find_nodes_in_area (p0 , p1 , {" group:puts_out_fire" })
133
- return (# ps ~= 0 )
128
+ return minetest .find_node_near (pos , 1 , {" group:puts_out_fire" })
134
129
end
135
130
136
131
137
- -- Ignite neighboring nodes
132
+ -- Enable ABMs according to 'disable fire' setting
138
133
139
- minetest .register_abm ({
140
- nodenames = {" group:flammable" },
141
- neighbors = {" group:igniter" },
142
- interval = 7 ,
143
- chance = 32 ,
144
- action = function (p0 , node , _ , _ )
145
- -- If there is water or stuff like that around flame, don't ignite
146
- if fire .flame_should_extinguish (p0 ) then
147
- return
148
- end
149
- local p = fire .find_pos_for_flame_around (p0 )
150
- if p then
151
- minetest .set_node (p , {name = " fire:basic_flame" })
152
- end
153
- end ,
154
- })
134
+ if minetest .setting_getbool (" disable_fire" ) then
135
+
136
+ -- Extinguish flames quickly with dedicated ABM
137
+
138
+ minetest .register_abm ({
139
+ nodenames = {" fire:basic_flame" },
140
+ interval = 3 ,
141
+ chance = 2 ,
142
+ action = function (p0 , node , _ , _ )
143
+ minetest .remove_node (p0 )
144
+ end ,
145
+ })
146
+
147
+ else
148
+
149
+ -- Extinguish flames quickly with water, snow, ice
150
+
151
+ minetest .register_abm ({
152
+ nodenames = {" fire:basic_flame" },
153
+ neighbors = {" group:puts_out_fire" },
154
+ interval = 3 ,
155
+ chance = 2 ,
156
+ action = function (p0 , node , _ , _ )
157
+ minetest .remove_node (p0 )
158
+ minetest .sound_play (" fire_extinguish_flame" ,
159
+ {pos = p0 , max_hear_distance = 16 , gain = 0.25 })
160
+ end ,
161
+ })
162
+
163
+ -- Ignite neighboring nodes
164
+
165
+ minetest .register_abm ({
166
+ nodenames = {" group:flammable" },
167
+ neighbors = {" group:igniter" },
168
+ interval = 7 ,
169
+ chance = 16 ,
170
+ action = function (p0 , node , _ , _ )
171
+ -- If there is water or stuff like that around node, don't ignite
172
+ if fire .flame_should_extinguish (p0 ) then
173
+ return
174
+ end
175
+ local p = fire .find_pos_for_flame_around (p0 )
176
+ if p then
177
+ minetest .set_node (p , {name = " fire:basic_flame" })
178
+ end
179
+ end ,
180
+ })
181
+
182
+ -- Remove flames and flammable nodes
183
+
184
+ minetest .register_abm ({
185
+ nodenames = {" fire:basic_flame" },
186
+ interval = 5 ,
187
+ chance = 16 ,
188
+ action = function (p0 , node , _ , _ )
189
+ -- If there are no flammable nodes around flame, remove flame
190
+ if not minetest .find_node_near (p0 , 1 , {" group:flammable" }) then
191
+ minetest .remove_node (p0 )
192
+ return
193
+ end
194
+ if math.random (1 , 4 ) == 1 then
195
+ -- remove flammable nodes around flame
196
+ local p = minetest .find_node_near (p0 , 1 , {" group:flammable" })
197
+ if p then
198
+ minetest .remove_node (p )
199
+ nodeupdate (p )
200
+ end
201
+ end
202
+ end ,
203
+ })
204
+
205
+ end
155
206
156
207
157
208
-- Rarely ignite things from far
@@ -184,44 +235,3 @@ minetest.register_abm({
184
235
end,
185
236
})
186
237
--]]
187
-
188
-
189
- -- Remove flammable nodes and flame
190
-
191
- minetest .register_abm ({
192
- nodenames = {" fire:basic_flame" },
193
- interval = 5 ,
194
- chance = 16 ,
195
- action = function (p0 , node , _ , _ )
196
- -- If there is water or stuff like that around flame, remove flame
197
- if fire .flame_should_extinguish (p0 ) then
198
- minetest .remove_node (p0 )
199
- return
200
- end
201
- -- Make the following things rarer
202
- if math.random (1 , 3 ) == 1 then
203
- return
204
- end
205
- -- If there are no flammable nodes around flame, remove flame
206
- if not minetest .find_node_near (p0 , 1 , {" group:flammable" }) then
207
- minetest .remove_node (p0 )
208
- return
209
- end
210
- if math.random (1 , 4 ) == 1 then
211
- -- remove a flammable node around flame
212
- local p = minetest .find_node_near (p0 , 1 , {" group:flammable" })
213
- if p then
214
- -- If there is water or stuff like that around flame, don't remove
215
- if fire .flame_should_extinguish (p0 ) then
216
- return
217
- end
218
- minetest .remove_node (p )
219
- nodeupdate (p )
220
- end
221
- else
222
- -- remove flame
223
- minetest .remove_node (p0 )
224
- end
225
- end ,
226
- })
227
-
0 commit comments