Add sound volume controls

This commit is contained in:
RealBadAngel 2013-02-23 03:18:47 +01:00
parent 1a09ffaf49
commit 315881ef58

@ -37,6 +37,7 @@ end)
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
local player_name = player:get_player_name() local player_name = player:get_player_name()
table.insert(unified_inventory.players, player_name) table.insert(unified_inventory.players, player_name)
unified_inventory.players["sound_volume"]=minetest.setting_get("sound_volume")*10
unified_inventory.current_index[player_name] = 1 unified_inventory.current_index[player_name] = 1
unified_inventory.filtered_items_list[player_name] = {} unified_inventory.filtered_items_list[player_name] = {}
unified_inventory.filtered_items_list[player_name] = unified_inventory.items_list unified_inventory.filtered_items_list[player_name] = unified_inventory.items_list
@ -234,6 +235,9 @@ unified_inventory.get_formspec = function(player,page)
formspec=formspec.."button[0,2;2,0.5;misc_set_day;Set Day]" formspec=formspec.."button[0,2;2,0.5;misc_set_day;Set Day]"
formspec=formspec.."button[2,2;2,0.5;misc_set_night;Set Night]" formspec=formspec.."button[2,2;2,0.5;misc_set_night;Set Night]"
end end
formspec = formspec.."label[0,3;Sound volume: "..unified_inventory.players["sound_volume"].."]"
formspec=formspec.."button[2.5,3;1,0.5;misc_vol_down;-]"
formspec=formspec.."button[3.5,3;1,0.5;misc_vol_up;+]"
end end
--Items list --Items list
@ -320,6 +324,22 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
minetest.chat_send_player(player_name, "You don't have settime priviledge!") minetest.chat_send_player(player_name, "You don't have settime priviledge!")
end end
end end
if fields.misc_vol_down then
local sound_volume=unified_inventory.players["sound_volume"]
sound_volume=sound_volume-1
if sound_volume<0 then sound_volume=0 end
minetest.setting_set("sound_volume",sound_volume/10)
unified_inventory.players["sound_volume"]=sound_volume
unified_inventory.set_inventory_formspec(player, unified_inventory.get_formspec(player,"misc"))
end
if fields.misc_vol_up then
local sound_volume=unified_inventory.players["sound_volume"]
sound_volume=sound_volume+1
if sound_volume>10 then sound_volume=10 end
minetest.setting_set("sound_volume",sound_volume/10)
unified_inventory.players["sound_volume"]=sound_volume
unified_inventory.set_inventory_formspec(player, unified_inventory.get_formspec(player,"misc"))
end
-- Inventory page controls -- Inventory page controls
local start=math.floor(unified_inventory.current_index[player_name]/80 +1 ) local start=math.floor(unified_inventory.current_index[player_name]/80 +1 )