mirror of
https://codeberg.org/tenplus1/ambience.git
synced 2025-01-11 18:40:16 +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
|
-- global functions
|
||||||
ambience.add_set = function(set_name, def)
|
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] = {
|
sound_sets[set_name] = {
|
||||||
frequency = def.frequency or 50,
|
frequency = def.frequency or 50,
|
||||||
sounds = def.sounds,
|
sounds = def.sounds,
|
||||||
sound_check = def.sound_check,
|
sound_check = def.sound_check,
|
||||||
nodes = def.nodes,
|
nodes = def.nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
-- add set name to the sound_set_order table
|
-- add set name to the sound_set_order table
|
||||||
local can_add = true
|
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
|
if sound_set_order[i] == set_name then
|
||||||
can_add = false
|
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
|
||||||
end
|
|
||||||
|
|
||||||
if can_add then
|
if can_add then
|
||||||
table.insert(sound_set_order, set_name)
|
table.insert(set_nodes, can_add)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -89,9 +89,20 @@ ambience.add_set("river", {
|
|||||||
nodes = {"default:river_water_flowing"}
|
nodes = {"default:river_water_flowing"}
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
print ("[Ambience] found env_sounds, flowing water sounds disabled")
|
print ("[Ambience] found env_sounds, flowing water sounds disabled.")
|
||||||
end
|
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
|
-- Small fire sound plays when near flame, will get louder if more than 3
|
||||||
|
|
||||||
ambience.add_set("smallfire", {
|
ambience.add_set("smallfire", {
|
||||||
@ -101,17 +112,14 @@ ambience.add_set("smallfire", {
|
|||||||
},
|
},
|
||||||
sound_check = function(def)
|
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)
|
if c > 3 and c < 9 then
|
||||||
+ (def.totals["fire:permanent_flame"] or 0)
|
return "smallfire", 0.2
|
||||||
|
|
||||||
if c > 3 and c < 9 then
|
elseif c > 0 and c < 4 then
|
||||||
return "smallfire", 0.2
|
return "smallfire"
|
||||||
|
|
||||||
elseif c > 0 and c < 4 then
|
|
||||||
return "smallfire"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
nodes = {"fire:basic_flame", "fire:permanent_flame"}
|
nodes = {"fire:basic_flame", "fire:permanent_flame"}
|
||||||
@ -126,22 +134,21 @@ ambience.add_set("largefire", {
|
|||||||
},
|
},
|
||||||
sound_check = function(def)
|
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)
|
if c > 16 then
|
||||||
+ (def.totals["fire:permanent_flame"] or 0)
|
return "largefire", 0.4
|
||||||
|
|
||||||
if c > 16 then
|
elseif c > 8 then
|
||||||
return "largefire", 0.4
|
return "largefire"
|
||||||
|
|
||||||
elseif c > 8 then
|
|
||||||
return "largefire"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
nodes = {"fire:basic_flame", "fire:permanent_flame"}
|
nodes = {"fire:basic_flame", "fire:permanent_flame"}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
-- Lava sound plays when near lava, will get louder if more than 50
|
-- Lava sound plays when near lava, will get louder if more than 50
|
||||||
|
|
||||||
ambience.add_set("lava", {
|
ambience.add_set("lava", {
|
||||||
|
Loading…
Reference in New Issue
Block a user