mirror of
https://codeberg.org/tenplus1/ambience.git
synced 2024-12-24 01:30:30 +01:00
added flame_sound and fire redo check
This commit is contained in:
parent
7bb0275f1e
commit
b7f794c1fe
69
init.lua
69
init.lua
@ -22,46 +22,47 @@ local set_nodes = {} -- all the nodes needed for sets
|
||||
-- global functions
|
||||
ambience.add_set = function(set_name, def)
|
||||
|
||||
if set_name and def then
|
||||
if not set_name or not def then
|
||||
return
|
||||
end
|
||||
|
||||
sound_sets[set_name] = {
|
||||
frequency = def.frequency or 50,
|
||||
sounds = def.sounds,
|
||||
sound_check = def.sound_check,
|
||||
nodes = def.nodes,
|
||||
}
|
||||
sound_sets[set_name] = {
|
||||
frequency = def.frequency or 50,
|
||||
sounds = def.sounds,
|
||||
sound_check = def.sound_check,
|
||||
nodes = def.nodes
|
||||
}
|
||||
|
||||
-- add set name to the sound_set_order table
|
||||
local can_add = true
|
||||
-- add set name to the sound_set_order table
|
||||
local can_add = true
|
||||
|
||||
for i = 1, #sound_set_order do
|
||||
for i = 1, #sound_set_order do
|
||||
|
||||
if sound_set_order[i] == set_name then
|
||||
can_add = false
|
||||
if sound_set_order[i] == set_name then
|
||||
can_add = false
|
||||
end
|
||||
end
|
||||
|
||||
if can_add then
|
||||
table.insert(sound_set_order, set_name)
|
||||
end
|
||||
|
||||
-- add any missing nodes to the set_nodes table
|
||||
if def.nodes then
|
||||
|
||||
for i = 1, #def.nodes do
|
||||
|
||||
can_add = def.nodes[i]
|
||||
|
||||
for j = 1, #set_nodes do
|
||||
|
||||
if def.nodes[i] == set_nodes[j] then
|
||||
can_add = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if can_add then
|
||||
table.insert(sound_set_order, set_name)
|
||||
end
|
||||
|
||||
-- add any missing nodes to the set_nodes table
|
||||
if def.nodes then
|
||||
|
||||
for i = 1, #def.nodes do
|
||||
|
||||
can_add = def.nodes[i]
|
||||
|
||||
for j = 1, #set_nodes do
|
||||
|
||||
if def.nodes[i] == set_nodes[j] then
|
||||
can_add = false
|
||||
end
|
||||
end
|
||||
|
||||
if can_add then
|
||||
table.insert(set_nodes, can_add)
|
||||
end
|
||||
if can_add then
|
||||
table.insert(set_nodes, can_add)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -89,9 +89,20 @@ ambience.add_set("river", {
|
||||
nodes = {"default:river_water_flowing"}
|
||||
})
|
||||
else
|
||||
print ("[Ambience] found env_sounds, flowing water sounds disabled")
|
||||
print ("[Ambience] found env_sounds, flowing water sounds disabled.")
|
||||
end
|
||||
|
||||
-- Only add fire sounds set if flame_sound is disabled or fire redo active
|
||||
|
||||
local flame_sound = minetest.settings:get_bool("flame_sound", true)
|
||||
local fire_redo = minetest.get_modpath("fire") and fire.mod and fire.mod == "redo"
|
||||
|
||||
if flame_sound and not fire_redo then
|
||||
|
||||
print ("[Ambience] fire sounds not enabled, already active in fire mod.")
|
||||
|
||||
else
|
||||
|
||||
-- Small fire sound plays when near flame, will get louder if more than 3
|
||||
|
||||
ambience.add_set("smallfire", {
|
||||
@ -101,17 +112,14 @@ ambience.add_set("smallfire", {
|
||||
},
|
||||
sound_check = function(def)
|
||||
|
||||
if fire and fire.mod and fire.mod == "redo" then
|
||||
local c = (def.totals["fire:basic_flame"] or 0)
|
||||
+ (def.totals["fire:permanent_flame"] or 0)
|
||||
|
||||
local c = (def.totals["fire:basic_flame"] or 0)
|
||||
+ (def.totals["fire:permanent_flame"] or 0)
|
||||
if c > 3 and c < 9 then
|
||||
return "smallfire", 0.2
|
||||
|
||||
if c > 3 and c < 9 then
|
||||
return "smallfire", 0.2
|
||||
|
||||
elseif c > 0 and c < 4 then
|
||||
return "smallfire"
|
||||
end
|
||||
elseif c > 0 and c < 4 then
|
||||
return "smallfire"
|
||||
end
|
||||
end,
|
||||
nodes = {"fire:basic_flame", "fire:permanent_flame"}
|
||||
@ -126,22 +134,21 @@ ambience.add_set("largefire", {
|
||||
},
|
||||
sound_check = function(def)
|
||||
|
||||
if fire and fire.mod and fire.mod == "redo" then
|
||||
local c = (def.totals["fire:basic_flame"] or 0)
|
||||
+ (def.totals["fire:permanent_flame"] or 0)
|
||||
|
||||
local c = (def.totals["fire:basic_flame"] or 0)
|
||||
+ (def.totals["fire:permanent_flame"] or 0)
|
||||
if c > 16 then
|
||||
return "largefire", 0.4
|
||||
|
||||
if c > 16 then
|
||||
return "largefire", 0.4
|
||||
|
||||
elseif c > 8 then
|
||||
return "largefire"
|
||||
end
|
||||
elseif c > 8 then
|
||||
return "largefire"
|
||||
end
|
||||
end,
|
||||
nodes = {"fire:basic_flame", "fire:permanent_flame"}
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
-- Lava sound plays when near lava, will get louder if more than 50
|
||||
|
||||
ambience.add_set("lava", {
|
||||
|
Loading…
Reference in New Issue
Block a user