Browse Source

Add feedback sounds for table-related actions, and make sounds play for everyone

tags/1.0
Hugues Ross 3 months ago
parent
commit
19ca1bf0f1
4 changed files with 22 additions and 3 deletions
  1. +3
    -3
      items.lua
  2. +7
    -0
      map_api.lua
  3. BIN
      sounds/cartographer_turn_page.ogg
  4. +12
    -0
      table.lua

+ 3
- 3
items.lua View File

@@ -85,7 +85,7 @@ minetest.register_on_player_receive_fields(function(player, name, fields)
local player_x, player_z = cartographer.to_map_coordinates(map, pos.x, pos.z);
cartographer.set_marker(map, player_x, player_z, marker);

minetest.sound_play("cartographer_write", { to_player=player:get_player_name() }, true);
cartographer.map_sound("cartographer_write", player);
show_map_id_formspec(map.id, pos.x, pos.z, player:get_player_name(), data.page);
elseif k == "prev_button" then
show_map_id_formspec(map.id, pos.x, pos.z, player:get_player_name(), data.page - 1);
@@ -136,7 +136,7 @@ minetest.register_node("cartographer:map", {
-- pos: The position of the node
-- player: The player that right-clicked the node
on_rightclick = function(pos, _, player)
minetest.sound_play("cartographer_open_map", { to_player=name }, true);
cartographer.map_sound("cartographer_open_map", player);
show_map_meta(minetest.get_meta(pos), player);
end,

@@ -145,7 +145,7 @@ minetest.register_node("cartographer:map", {
-- stack: The itemstack
-- player: The player that used the item
on_use = function(stack, player)
minetest.sound_play("cartographer_open_map", { to_player=name }, true);
cartographer.map_sound("cartographer_open_map", player);
show_map_meta(stack:get_meta(), player);
end,
});


+ 7
- 0
map_api.lua View File

@@ -257,3 +257,10 @@ function cartographer.get_marker_texture(id, detail)

return nil;
end

-- Play a feedback sound localized on the given player
-- sound: The sound to play
-- player: The player who triggered the sound
function cartographer.map_sound(sound, player)
minetest.sound_play(sound, { pos=player:get_pos(), max_hear_distance=5 }, true);
end

BIN
sounds/cartographer_turn_page.ogg View File


+ 12
- 0
table.lua View File

@@ -368,6 +368,7 @@ minetest.register_on_player_receive_fields(function(player, name, fields)
meta:set_int("paper", paper);
meta:set_int("pigment", pigment);

cartographer.map_sound("cartographer_write", player);
inv:set_stack("output", 1, cartographer.create_map_item(size, 1 + detail, scale));
end
else
@@ -387,6 +388,7 @@ minetest.register_on_player_receive_fields(function(player, name, fields)
if map ~= nil then
map.detail = 1 + detail;
end
cartographer.map_sound("cartographer_write", player);
inv:set_stack("output", 1, stack);
end
end
@@ -413,6 +415,7 @@ minetest.register_on_player_receive_fields(function(player, name, fields)
meta:set_int("paper", paper);
meta:set_int("pigment", pigment);

cartographer.map_sound("cartographer_write", player);
inv:set_stack("copy_output", 1, cartographer.copy_map_item(in_stack));
end
end
@@ -443,10 +446,13 @@ minetest.register_on_player_receive_fields(function(player, name, fields)
meta:set_int("scale", SCALE_LARGE);
table_formspec(player:get_player_name(), 2)
elseif fields["tab1"] ~= nil then
cartographer.map_sound("cartographer_turn_page", player);
table_formspec(player:get_player_name(), 1);
elseif fields["tab2"] ~= nil then
cartographer.map_sound("cartographer_turn_page", player);
table_formspec(player:get_player_name(), 2);
elseif fields["tab3"] ~= nil then
cartographer.map_sound("cartographer_turn_page", player);
table_formspec(player:get_player_name(), 3);
end
end
@@ -488,6 +494,8 @@ minetest.register_node("cartographer:simple_table", {
},
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
player_tables[player:get_player_name()] = minetest.get_pointed_thing_position(pointed_thing);

cartographer.map_sound("cartographer_open_map", player);
table_formspec(player:get_player_name(), 1)
end,

@@ -518,6 +526,8 @@ minetest.register_node("cartographer:standard_table", {
},
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
player_tables[player:get_player_name()] = minetest.get_pointed_thing_position(pointed_thing);

cartographer.map_sound("cartographer_open_map", player);
table_formspec(player:get_player_name(), 1)
end,

@@ -548,6 +558,8 @@ minetest.register_node("cartographer:advanced_table", {
},
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
player_tables[player:get_player_name()] = minetest.get_pointed_thing_position(pointed_thing);

cartographer.map_sound("cartographer_open_map", player);
table_formspec(player:get_player_name(), 1)
end,



Loading…
Cancel
Save