diff options
author | cheapie <no-email-for-you@example.com> | 2018-08-07 19:15:34 -0500 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2018-08-07 19:15:34 -0500 |
commit | bc19da21d3f4f94ec705c0a7dbc81cdbbb37fda5 (patch) | |
tree | b1324e641709a199f5cc7e1ad8d55e605a73f4d0 /init.lua | |
parent | 6d4a619de7187c2fce65a9f35393d3cfcfc9ec86 (diff) | |
download | digistuff-bc19da21d3f4f94ec705c0a7dbc81cdbbb37fda5.tar digistuff-bc19da21d3f4f94ec705c0a7dbc81cdbbb37fda5.tar.gz digistuff-bc19da21d3f4f94ec705c0a7dbc81cdbbb37fda5.tar.bz2 digistuff-bc19da21d3f4f94ec705c0a7dbc81cdbbb37fda5.tar.xz digistuff-bc19da21d3f4f94ec705c0a7dbc81cdbbb37fda5.zip |
Enable playing sounds from other mods via the digilines noteblock
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 45 |
1 files changed, 10 insertions, 35 deletions
@@ -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)) |