summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2018-08-07 19:15:34 -0500
committercheapie <no-email-for-you@example.com>2018-08-07 19:15:34 -0500
commitbc19da21d3f4f94ec705c0a7dbc81cdbbb37fda5 (patch)
treeb1324e641709a199f5cc7e1ad8d55e605a73f4d0 /init.lua
parent6d4a619de7187c2fce65a9f35393d3cfcfc9ec86 (diff)
downloaddigistuff-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.lua45
1 files changed, 10 insertions, 35 deletions
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))