diff options
author | cheapie <no-email-for-you@example.com> | 2016-12-04 22:04:12 -0600 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2016-12-04 22:04:12 -0600 |
commit | 6273c27d944151404ce046aab5a03043be7a17e8 (patch) | |
tree | 65011f5596f738fabf0941a2ebc0540fd17a10b7 | |
parent | 0cdbfe2be18c94e16c4cbf5c6aa96fde3dcdc344 (diff) | |
download | digistuff-6273c27d944151404ce046aab5a03043be7a17e8.tar digistuff-6273c27d944151404ce046aab5a03043be7a17e8.tar.gz digistuff-6273c27d944151404ce046aab5a03043be7a17e8.tar.bz2 digistuff-6273c27d944151404ce046aab5a03043be7a17e8.tar.xz digistuff-6273c27d944151404ce046aab5a03043be7a17e8.zip |
Add piezo beeper
-rw-r--r-- | init.lua | 80 | ||||
-rw-r--r-- | sounds/digistuff_piezo_fast_repeat.ogg | bin | 0 -> 5515 bytes | |||
-rw-r--r-- | sounds/digistuff_piezo_long_single.ogg | bin | 0 -> 6637 bytes | |||
-rw-r--r-- | sounds/digistuff_piezo_short_single.ogg | bin | 0 -> 4672 bytes | |||
-rw-r--r-- | sounds/digistuff_piezo_slow_repeat.ogg | bin | 0 -> 5219 bytes | |||
-rw-r--r-- | textures/digistuff_piezo_sides.png | bin | 0 -> 3187 bytes | |||
-rw-r--r-- | textures/digistuff_piezo_top.png | bin | 0 -> 2663 bytes |
7 files changed, 80 insertions, 0 deletions
@@ -1,4 +1,5 @@ digistuff = {} +digistuff.sounds_playing = {} digistuff.update_panel_formspec = function (pos,dispstr) local meta = minetest.get_meta(pos) @@ -676,3 +677,82 @@ minetest.register_node("digistuff:touchscreen", { }, }, }) + +minetest.register_node("digistuff:piezo", { + description = "Digilines Piezoelectric Beeper", + 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 = { + "digistuff_piezo_top.png", + "digistuff_piezo_sides.png", + "digistuff_piezo_sides.png", + "digistuff_piezo_sides.png", + "digistuff_piezo_sides.png", + "digistuff_piezo_sides.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 + if msg == "shortbeep" then + 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 + minetest.sound_play({name = "digistuff_piezo_short_single",gain = 0.2},{pos = pos,max_hear_distance = 16}) + elseif msg == "longbeep" then + 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 + minetest.sound_play({name = "digistuff_piezo_long_single",gain = 0.2},{pos = pos,max_hear_distance = 16}) + elseif msg == "fastrepeat" then + 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 + digistuff.sounds_playing[pos_hash] = minetest.sound_play({name = "digistuff_piezo_fast_repeat",gain = 0.2},{pos = pos,max_hear_distance = 16,loop = true}) + elseif msg == "slowrepeat" then + 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 + digistuff.sounds_playing[pos_hash] = minetest.sound_play({name = "digistuff_piezo_slow_repeat",gain = 0.2},{pos = pos,max_hear_distance = 16,loop = true}) + elseif msg == "stop" then + 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 + end + }, + }, +}) diff --git a/sounds/digistuff_piezo_fast_repeat.ogg b/sounds/digistuff_piezo_fast_repeat.ogg Binary files differnew file mode 100644 index 0000000..be035da --- /dev/null +++ b/sounds/digistuff_piezo_fast_repeat.ogg diff --git a/sounds/digistuff_piezo_long_single.ogg b/sounds/digistuff_piezo_long_single.ogg Binary files differnew file mode 100644 index 0000000..435ac61 --- /dev/null +++ b/sounds/digistuff_piezo_long_single.ogg diff --git a/sounds/digistuff_piezo_short_single.ogg b/sounds/digistuff_piezo_short_single.ogg Binary files differnew file mode 100644 index 0000000..0178f15 --- /dev/null +++ b/sounds/digistuff_piezo_short_single.ogg diff --git a/sounds/digistuff_piezo_slow_repeat.ogg b/sounds/digistuff_piezo_slow_repeat.ogg Binary files differnew file mode 100644 index 0000000..1b35343 --- /dev/null +++ b/sounds/digistuff_piezo_slow_repeat.ogg diff --git a/textures/digistuff_piezo_sides.png b/textures/digistuff_piezo_sides.png Binary files differnew file mode 100644 index 0000000..7d66228 --- /dev/null +++ b/textures/digistuff_piezo_sides.png diff --git a/textures/digistuff_piezo_top.png b/textures/digistuff_piezo_top.png Binary files differnew file mode 100644 index 0000000..44f8e07 --- /dev/null +++ b/textures/digistuff_piezo_top.png |