From bc19da21d3f4f94ec705c0a7dbc81cdbbb37fda5 Mon Sep 17 00:00:00 2001 From: cheapie Date: Tue, 7 Aug 2018 19:15:34 -0500 Subject: Enable playing sounds from other mods via the digilines noteblock --- init.lua | 45 ++++++++++----------------------------------- 1 file changed, 10 insertions(+), 35 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index b35cb1b..351fb6b 100644 --- a/init.lua +++ b/init.lua @@ -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)) -- cgit v1.2.3