Remove flame sound setting and audio section
This commit is contained in:
parent
b91ba944b6
commit
1d5eac59f2
@ -57,9 +57,6 @@ local smoke_pdef = {
|
||||
-- When enabled, fire destroys other blocks.
|
||||
local fire_enabled = minetest.settings:get_bool("enable_fire", true)
|
||||
|
||||
-- Enable sound
|
||||
local flame_sound = minetest.settings:get_bool("flame_sound", true)
|
||||
|
||||
-- Help texts
|
||||
local fire_help, eternal_fire_help
|
||||
if fire_enabled then
|
||||
@ -180,112 +177,109 @@ minetest.register_node("mcl_fire:eternal_fire", {
|
||||
-- Sound
|
||||
--
|
||||
|
||||
if flame_sound then
|
||||
local handles = {}
|
||||
local timer = 0
|
||||
|
||||
local handles = {}
|
||||
local timer = 0
|
||||
-- Parameters
|
||||
|
||||
-- Parameters
|
||||
local radius = 8 -- Flame node search radius around player
|
||||
local cycle = 3 -- Cycle time for sound updates
|
||||
|
||||
local radius = 8 -- Flame node search radius around player
|
||||
local cycle = 3 -- Cycle time for sound updates
|
||||
-- Update sound for player
|
||||
|
||||
-- Update sound for player
|
||||
|
||||
function mcl_fire.update_player_sound(player)
|
||||
local player_name = player:get_player_name()
|
||||
-- Search for flame nodes in radius around player
|
||||
local ppos = player:get_pos()
|
||||
local areamin = vector.subtract(ppos, radius)
|
||||
local areamax = vector.add(ppos, radius)
|
||||
local fpos, num = minetest.find_nodes_in_area(
|
||||
areamin,
|
||||
areamax,
|
||||
{"mcl_fire:fire", "mcl_fire:eternal_fire"}
|
||||
)
|
||||
-- Total number of flames in radius
|
||||
local flames = (num["mcl_fire:fire"] or 0) +
|
||||
(num["mcl_fire:eternal_fire"] or 0)
|
||||
-- Stop previous sound
|
||||
if handles[player_name] then
|
||||
minetest.sound_fade(handles[player_name], -0.4, 0.0)
|
||||
handles[player_name] = nil
|
||||
end
|
||||
-- If flames
|
||||
if flames > 0 then
|
||||
-- Find centre of flame positions
|
||||
local fposmid = fpos[1]
|
||||
-- If more than 1 flame
|
||||
if #fpos > 1 then
|
||||
local fposmin = areamax
|
||||
local fposmax = areamin
|
||||
for i = 1, #fpos do
|
||||
local fposi = fpos[i]
|
||||
if fposi.x > fposmax.x then
|
||||
fposmax.x = fposi.x
|
||||
end
|
||||
if fposi.y > fposmax.y then
|
||||
fposmax.y = fposi.y
|
||||
end
|
||||
if fposi.z > fposmax.z then
|
||||
fposmax.z = fposi.z
|
||||
end
|
||||
if fposi.x < fposmin.x then
|
||||
fposmin.x = fposi.x
|
||||
end
|
||||
if fposi.y < fposmin.y then
|
||||
fposmin.y = fposi.y
|
||||
end
|
||||
if fposi.z < fposmin.z then
|
||||
fposmin.z = fposi.z
|
||||
end
|
||||
function mcl_fire.update_player_sound(player)
|
||||
local player_name = player:get_player_name()
|
||||
-- Search for flame nodes in radius around player
|
||||
local ppos = player:get_pos()
|
||||
local areamin = vector.subtract(ppos, radius)
|
||||
local areamax = vector.add(ppos, radius)
|
||||
local fpos, num = minetest.find_nodes_in_area(
|
||||
areamin,
|
||||
areamax,
|
||||
{"mcl_fire:fire", "mcl_fire:eternal_fire"}
|
||||
)
|
||||
-- Total number of flames in radius
|
||||
local flames = (num["mcl_fire:fire"] or 0) +
|
||||
(num["mcl_fire:eternal_fire"] or 0)
|
||||
-- Stop previous sound
|
||||
if handles[player_name] then
|
||||
minetest.sound_fade(handles[player_name], -0.4, 0.0)
|
||||
handles[player_name] = nil
|
||||
end
|
||||
-- If flames
|
||||
if flames > 0 then
|
||||
-- Find centre of flame positions
|
||||
local fposmid = fpos[1]
|
||||
-- If more than 1 flame
|
||||
if #fpos > 1 then
|
||||
local fposmin = areamax
|
||||
local fposmax = areamin
|
||||
for i = 1, #fpos do
|
||||
local fposi = fpos[i]
|
||||
if fposi.x > fposmax.x then
|
||||
fposmax.x = fposi.x
|
||||
end
|
||||
if fposi.y > fposmax.y then
|
||||
fposmax.y = fposi.y
|
||||
end
|
||||
if fposi.z > fposmax.z then
|
||||
fposmax.z = fposi.z
|
||||
end
|
||||
if fposi.x < fposmin.x then
|
||||
fposmin.x = fposi.x
|
||||
end
|
||||
if fposi.y < fposmin.y then
|
||||
fposmin.y = fposi.y
|
||||
end
|
||||
if fposi.z < fposmin.z then
|
||||
fposmin.z = fposi.z
|
||||
end
|
||||
fposmid = vector.divide(vector.add(fposmin, fposmax), 2)
|
||||
end
|
||||
-- Play sound
|
||||
local handle = minetest.sound_play(
|
||||
"fire_fire",
|
||||
{
|
||||
pos = fposmid,
|
||||
to_player = player_name,
|
||||
gain = math.min(0.06 * (1 + flames * 0.125), 0.18),
|
||||
max_hear_distance = 32,
|
||||
loop = true, -- In case of lag
|
||||
}
|
||||
)
|
||||
-- Store sound handle for this player
|
||||
if handle then
|
||||
handles[player_name] = handle
|
||||
end
|
||||
fposmid = vector.divide(vector.add(fposmin, fposmax), 2)
|
||||
end
|
||||
-- Play sound
|
||||
local handle = minetest.sound_play(
|
||||
"fire_fire",
|
||||
{
|
||||
pos = fposmid,
|
||||
to_player = player_name,
|
||||
gain = math.min(0.06 * (1 + flames * 0.125), 0.18),
|
||||
max_hear_distance = 32,
|
||||
loop = true, -- In case of lag
|
||||
}
|
||||
)
|
||||
-- Store sound handle for this player
|
||||
if handle then
|
||||
handles[player_name] = handle
|
||||
end
|
||||
end
|
||||
|
||||
-- Cycle for updating players sounds
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
timer = timer + dtime
|
||||
if timer < cycle then
|
||||
return
|
||||
end
|
||||
|
||||
timer = 0
|
||||
local players = minetest.get_connected_players()
|
||||
for n = 1, #players do
|
||||
mcl_fire.update_player_sound(players[n])
|
||||
end
|
||||
end)
|
||||
|
||||
-- Stop sound and clear handle on player leave
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local player_name = player:get_player_name()
|
||||
if handles[player_name] then
|
||||
minetest.sound_stop(handles[player_name])
|
||||
handles[player_name] = nil
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- Cycle for updating players sounds
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
timer = timer + dtime
|
||||
if timer < cycle then
|
||||
return
|
||||
end
|
||||
|
||||
timer = 0
|
||||
local players = minetest.get_connected_players()
|
||||
for n = 1, #players do
|
||||
mcl_fire.update_player_sound(players[n])
|
||||
end
|
||||
end)
|
||||
|
||||
-- Stop sound and clear handle on player leave
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local player_name = player:get_player_name()
|
||||
if handles[player_name] then
|
||||
minetest.sound_stop(handles[player_name])
|
||||
handles[player_name] = nil
|
||||
end
|
||||
end)
|
||||
|
||||
-- [...]a fire that is not adjacent to any flammable block does not spread, even to another flammable block within the normal range.
|
||||
-- https://minecraft.fandom.com/wiki/Fire#Spread
|
||||
|
||||
|
@ -120,11 +120,6 @@ mcl_old_spawn_icons (Old spawn icons instead of eggs) bool false
|
||||
# Larger values will have a larger performance impact (default:48)
|
||||
mcl_mob_active_range (Active mob range) int 48 0 256
|
||||
|
||||
|
||||
[Audio]
|
||||
# Enable flame sound.
|
||||
flame_sound (Flame sound) bool true
|
||||
|
||||
[Graphics]
|
||||
# How many vertical animation frames the fire texture (fire_basic_flame_animated.png) has.
|
||||
# This may vary depending on the texture pack you use.
|
||||
|
Loading…
x
Reference in New Issue
Block a user