Add feedback sounds for table-related actions, and make sounds play for everyone
This commit is contained in:
parent
fa95a8705e
commit
19ca1bf0f1
@ -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);
|
local player_x, player_z = cartographer.to_map_coordinates(map, pos.x, pos.z);
|
||||||
cartographer.set_marker(map, player_x, player_z, marker);
|
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);
|
show_map_id_formspec(map.id, pos.x, pos.z, player:get_player_name(), data.page);
|
||||||
elseif k == "prev_button" then
|
elseif k == "prev_button" then
|
||||||
show_map_id_formspec(map.id, pos.x, pos.z, player:get_player_name(), data.page - 1);
|
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
|
-- pos: The position of the node
|
||||||
-- player: The player that right-clicked the node
|
-- player: The player that right-clicked the node
|
||||||
on_rightclick = function(pos, _, player)
|
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);
|
show_map_meta(minetest.get_meta(pos), player);
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ minetest.register_node("cartographer:map", {
|
|||||||
-- stack: The itemstack
|
-- stack: The itemstack
|
||||||
-- player: The player that used the item
|
-- player: The player that used the item
|
||||||
on_use = function(stack, player)
|
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);
|
show_map_meta(stack:get_meta(), player);
|
||||||
end,
|
end,
|
||||||
});
|
});
|
||||||
|
@ -257,3 +257,10 @@ function cartographer.get_marker_texture(id, detail)
|
|||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
end
|
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
Normal file
BIN
sounds/cartographer_turn_page.ogg
Normal file
Binary file not shown.
12
table.lua
12
table.lua
@ -368,6 +368,7 @@ minetest.register_on_player_receive_fields(function(player, name, fields)
|
|||||||
meta:set_int("paper", paper);
|
meta:set_int("paper", paper);
|
||||||
meta:set_int("pigment", pigment);
|
meta:set_int("pigment", pigment);
|
||||||
|
|
||||||
|
cartographer.map_sound("cartographer_write", player);
|
||||||
inv:set_stack("output", 1, cartographer.create_map_item(size, 1 + detail, scale));
|
inv:set_stack("output", 1, cartographer.create_map_item(size, 1 + detail, scale));
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -387,6 +388,7 @@ minetest.register_on_player_receive_fields(function(player, name, fields)
|
|||||||
if map ~= nil then
|
if map ~= nil then
|
||||||
map.detail = 1 + detail;
|
map.detail = 1 + detail;
|
||||||
end
|
end
|
||||||
|
cartographer.map_sound("cartographer_write", player);
|
||||||
inv:set_stack("output", 1, stack);
|
inv:set_stack("output", 1, stack);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -413,6 +415,7 @@ minetest.register_on_player_receive_fields(function(player, name, fields)
|
|||||||
meta:set_int("paper", paper);
|
meta:set_int("paper", paper);
|
||||||
meta:set_int("pigment", pigment);
|
meta:set_int("pigment", pigment);
|
||||||
|
|
||||||
|
cartographer.map_sound("cartographer_write", player);
|
||||||
inv:set_stack("copy_output", 1, cartographer.copy_map_item(in_stack));
|
inv:set_stack("copy_output", 1, cartographer.copy_map_item(in_stack));
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -443,10 +446,13 @@ minetest.register_on_player_receive_fields(function(player, name, fields)
|
|||||||
meta:set_int("scale", SCALE_LARGE);
|
meta:set_int("scale", SCALE_LARGE);
|
||||||
table_formspec(player:get_player_name(), 2)
|
table_formspec(player:get_player_name(), 2)
|
||||||
elseif fields["tab1"] ~= nil then
|
elseif fields["tab1"] ~= nil then
|
||||||
|
cartographer.map_sound("cartographer_turn_page", player);
|
||||||
table_formspec(player:get_player_name(), 1);
|
table_formspec(player:get_player_name(), 1);
|
||||||
elseif fields["tab2"] ~= nil then
|
elseif fields["tab2"] ~= nil then
|
||||||
|
cartographer.map_sound("cartographer_turn_page", player);
|
||||||
table_formspec(player:get_player_name(), 2);
|
table_formspec(player:get_player_name(), 2);
|
||||||
elseif fields["tab3"] ~= nil then
|
elseif fields["tab3"] ~= nil then
|
||||||
|
cartographer.map_sound("cartographer_turn_page", player);
|
||||||
table_formspec(player:get_player_name(), 3);
|
table_formspec(player:get_player_name(), 3);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -488,6 +494,8 @@ minetest.register_node("cartographer:simple_table", {
|
|||||||
},
|
},
|
||||||
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
||||||
player_tables[player:get_player_name()] = minetest.get_pointed_thing_position(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)
|
table_formspec(player:get_player_name(), 1)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -518,6 +526,8 @@ minetest.register_node("cartographer:standard_table", {
|
|||||||
},
|
},
|
||||||
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
||||||
player_tables[player:get_player_name()] = minetest.get_pointed_thing_position(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)
|
table_formspec(player:get_player_name(), 1)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -548,6 +558,8 @@ minetest.register_node("cartographer:advanced_table", {
|
|||||||
},
|
},
|
||||||
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
||||||
player_tables[player:get_player_name()] = minetest.get_pointed_thing_position(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)
|
table_formspec(player:get_player_name(), 1)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user