Fire ambiance consolidation

- Fire flame and torch flame use the same ambiance def via
  a new flame_ambiance group.
- Items can now emit ambiance via AISM.
This commit is contained in:
Aaron Suen 2020-05-26 18:48:03 -04:00
parent 63d9c3fdec
commit 55efdfa027
5 changed files with 28 additions and 15 deletions

View File

@ -5,7 +5,7 @@ local math_random
= math.random
-- LUALOCALS > ---------------------------------------------------------
function nodecore.register_ambiance(def)
local function ambiance_core(def, getpos)
local max = def.queue_max or 100
local rate = 1 / (def.queue_rate or 20)
@ -38,7 +38,8 @@ function nodecore.register_ambiance(def)
end
end)
def.action = function(pos)
def.action = function(...)
local pos = getpos(...)
local hash = minetest.hash_node_position(pos)
if seen[hash] then return end
seen[hash] = true
@ -60,6 +61,16 @@ function nodecore.register_ambiance(def)
end
total = total + 1
end
end
local function abm_pos(pos) return pos end
function nodecore.register_ambiance(def)
ambiance_core(def, abm_pos)
return nodecore.register_limited_abm(def)
end
local function aism_pos(_, data) return data.pos end
function nodecore.register_item_ambiance(def)
ambiance_core(def, aism_pos)
return nodecore.register_aism(def)
end

View File

@ -116,9 +116,18 @@ nodecore.register_limited_abm({
nodecore.register_ambiance({
label = "Flame Ambiance",
nodenames = {modname .. ":fire"},
nodenames = {"group:flame_ambiance"},
interval = 1,
chance = 1,
sound_name = "nc_fire_flamy",
sound_gain = 0.3
sound_gain = 0.1
})
nodecore.register_item_ambiance({
label = "Flame Ambiance",
itemnames = {"group:flame_ambiance"},
interval = 1,
chance = 1,
sound_name = "nc_fire_flamy",
sound_gain = 0.1
})

View File

@ -30,7 +30,8 @@ minetest.register_node(modname .. ":fire", {
flame_sound = 1,
stack_as_node = 1,
damage_touch = 1,
damage_radiant = 1
damage_radiant = 1,
flame_ambiance = 1
},
damage_per_second = 1,
sunlight_propagates = true,

View File

@ -96,12 +96,3 @@ nodecore.register_aism({
end
end
})
nodecore.register_ambiance({
label = "Flame Ambiance",
nodenames = {modname .. ":torch_lit"},
interval = 1,
chance = 1,
sound_name = "nc_fire_flamy",
sound_gain = 0.1
})

View File

@ -83,7 +83,8 @@ for i = 1, nodecore.torch_life_stages do
snappy = 1,
falling_repose = 1,
stack_as_node = 1,
torch_lit = 1
torch_lit = 1,
flame_ambiance = 1
},
stack_max = 1,
sounds = nodecore.sounds("nc_tree_sticky"),