add tuning sound

This commit is contained in:
techniX 2019-12-08 20:27:24 +02:00
parent a4160c1563
commit 364bcc4671
9 changed files with 15 additions and 2 deletions

@ -20,8 +20,11 @@ minetest.register_node("ham_radio:beacon", {
light_source = 3,
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos);
local name = placer:get_player_name()
meta:set_string('operated_by', name)
if minetest.is_player(placer) then
local name = placer:get_player_name()
meta:set_string('operated_by', name)
ham_radio.play_tuning_sound(placer)
end
meta:set_string("frequency", ham_radio.find_free_frequency(ham_radio.settings.beacon_frequency))
ham_radio.transmitter_update_infotext(meta)
ham_radio.save_transmitter(pos, meta)

@ -33,6 +33,13 @@ function ham_radio.delete_transmitter(pos)
mod_storage:set_string(key, '') -- storage
end
function ham_radio.play_tuning_sound(player)
minetest.sound_play(
{name = "ham_radio_tuning"..math.random(1,5)},
{to_player = player:get_player_name()}
)
end
dofile(modpath.."/config.lua")
dofile(modpath.."/helpers.lua")

@ -43,6 +43,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
local item = player:get_wielded_item()
local meta = item:get_meta()
meta:set_string("frequency", fields.frequency)
-- play radio sound
ham_radio.play_tuning_sound(player)
-- replace wielded item with new metadata
player:set_wielded_item(item)
-- reset rds messages

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -72,6 +72,7 @@ minetest.register_node("ham_radio:transmitter", {
meta:set_string("rds_message", fields.rds_message)
ham_radio.transmitter_update_infotext(meta)
ham_radio.save_transmitter(pos, meta)
ham_radio.play_tuning_sound(sender)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);