Enable playing sounds from other mods via the digilines noteblock

This commit is contained in:
cheapie
2018-08-07 19:15:34 -05:00
parent 6d4a619de7
commit bc19da21d3
2 changed files with 176 additions and 35 deletions

View File

@@ -930,6 +930,7 @@ minetest.register_craft({
})
if minetest.get_modpath("mesecons_noteblock") then
local validnbsounds = dofile(minetest.get_modpath("digistuff")..DIR_DELIM.."nbsounds.lua")
minetest.register_node("digistuff:noteblock", {
description = "Digilines Noteblock",
groups = {cracky=3},
@@ -961,48 +962,22 @@ if minetest.get_modpath("mesecons_noteblock") then
receptor = {},
effector = {
action = function(pos,node,channel,msg)
if msg == "get_sounds" then
local soundnames = {}
for i in pairs(validnbsounds) do
table.insert(soundnames,i)
end
digiline:receptor_send(pos, digiline.rules.default, channel, soundnames)
end
local meta = minetest.get_meta(pos)
local setchan = meta:get_string("channel")
if channel ~= setchan then return end
local valid_sounds = {
csharp = "mesecons_noteblock_csharp",
d = "mesecons_noteblock_d",
dsharp = "mesecons_noteblock_dsharp",
e = "mesecons_noteblock_e",
f = "mesecons_noteblock_f",
fsharp = "mesecons_noteblock_fsharp",
g = "mesecons_noteblock_g",
gsharp = "mesecons_noteblock_gsharp",
a = "mesecons_noteblock_a",
asharp = "mesecons_noteblock_asharp",
b = "mesecons_noteblock_b",
c = "mesecons_noteblock_c",
csharp2 = "mesecons_noteblock_csharp2",
d2 = "mesecons_noteblock_d2",
dsharp2 = "mesecons_noteblock_dsharp2",
e2 = "mesecons_noteblock_e2",
f2 = "mesecons_noteblock_f2",
fsharp2 = "mesecons_noteblock_fsharp2",
g2 = "mesecons_noteblock_g2",
gsharp2 = "mesecons_noteblock_gsharp2",
a2 = "mesecons_noteblock_a2",
asharp2 = "mesecons_noteblock_asharp2",
b2 = "mesecons_noteblock_b2",
c2 = "mesecons_noteblock_c2",
hihat = "mesecons_noteblock_hihat",
kick = "mesecons_noteblock_kick",
snare = "mesecons_noteblock_snare",
crash = "mesecons_noteblock_crash",
litecrash = "mesecons_noteblock_litecrash",
fire = "fire_large",
explosion = "tnt_explode"
}
if type(msg) == "string" then
local sound = valid_sounds[msg]
local sound = validnbsounds[msg]
if sound then minetest.sound_play(sound,{pos=pos}) end
elseif type(msg) == "table" then
if type(msg.sound) ~= "string" then return end
local sound = valid_sounds[msg.sound]
local sound = validnbsounds[msg.sound]
local volume = 1
if type(msg.volume) == "number" then
volume = math.max(0,math.min(1,msg.volume))