summaryrefslogtreecommitdiff
path: root/digistuff
diff options
context:
space:
mode:
authorVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2018-08-03 09:31:05 -0400
committerVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2018-08-03 09:31:05 -0400
commit2fa93b219eadfcdcf8f1d472aad046fc62d5b99d (patch)
treecff2e96e78cd89aa965976553d2ff8989b5a02b5 /digistuff
parent76594f4bd5f825eaf1245965e2c0933bec47320d (diff)
downloaddreambuilder_modpack-2fa93b219eadfcdcf8f1d472aad046fc62d5b99d.tar
dreambuilder_modpack-2fa93b219eadfcdcf8f1d472aad046fc62d5b99d.tar.gz
dreambuilder_modpack-2fa93b219eadfcdcf8f1d472aad046fc62d5b99d.tar.bz2
dreambuilder_modpack-2fa93b219eadfcdcf8f1d472aad046fc62d5b99d.tar.xz
dreambuilder_modpack-2fa93b219eadfcdcf8f1d472aad046fc62d5b99d.zip
update castles, cottages, digistuff, gloopblocks, locks,
maptools, mesecons, pipeworks, technic, unified inventory, unified dyes, and xban2
Diffstat (limited to 'digistuff')
-rw-r--r--digistuff/init.lua86
1 files changed, 86 insertions, 0 deletions
diff --git a/digistuff/init.lua b/digistuff/init.lua
index bcb7ce7..b35cb1b 100644
--- a/digistuff/init.lua
+++ b/digistuff/init.lua
@@ -928,3 +928,89 @@ minetest.register_craft({
{"homedecor:plastic_sheeting","homedecor:plastic_sheeting","homedecor:plastic_sheeting"},
}
})
+
+if minetest.get_modpath("mesecons_noteblock") then
+ minetest.register_node("digistuff:noteblock", {
+ description = "Digilines Noteblock",
+ groups = {cracky=3},
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("formspec","field[channel;Channel;${channel}")
+ end,
+ on_destruct = function(pos)
+ local pos_hash = minetest.hash_node_position(pos)
+ if digistuff.sounds_playing[pos_hash] then
+ minetest.sound_stop(digistuff.sounds_playing[pos_hash])
+ digistuff.sounds_playing[pos_hash] = nil
+ end
+ end,
+ tiles = {
+ "mesecons_noteblock.png"
+ },
+ on_receive_fields = function(pos, formname, fields, sender)
+ local name = sender:get_player_name()
+ if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then
+ minetest.record_protection_violation(pos,name)
+ return
+ end
+ local meta = minetest.get_meta(pos)
+ if fields.channel then meta:set_string("channel",fields.channel) end
+ end,
+ digiline =
+ {
+ receptor = {},
+ effector = {
+ action = function(pos,node,channel,msg)
+ 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]
+ 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 volume = 1
+ if type(msg.volume) == "number" then
+ volume = math.max(0,math.min(1,msg.volume))
+ end
+ if sound then minetest.sound_play({name=sound,gain=volume},{pos=pos}) end
+ end
+ end
+ },
+ },
+ })
+end