refactor + fix the volume button
This commit is contained in:
parent
b2167cf124
commit
10970edbc2
@ -1 +1,2 @@
|
||||
default
|
||||
inventory_plus?
|
||||
|
36
init.lua
36
init.lua
@ -605,20 +605,36 @@ minetest.register_on_joinplayer(function(player)
|
||||
volume[player:get_player_name()] = {music=MUSICVOLUME, sound=SOUNDVOLUME}
|
||||
end
|
||||
end)
|
||||
minetest.register_chatcommand("volume", {
|
||||
description = "View sliders to set sound a music volume",
|
||||
func = function(name,param)
|
||||
minetest.show_formspec(name, "ambience:volume",
|
||||
|
||||
local function show_formspec(name)
|
||||
minetest.show_formspec(name, "volume",
|
||||
"size[6,3.5]" ..
|
||||
"label[1.2,0;Hint: Your change will affect the *next* played title!]" ..
|
||||
"label[0,0.5;Music]" ..
|
||||
"scrollbar[0,1;5.8,0.4;horizontal;music;" .. volume[name].music * 1000 .. "]" ..
|
||||
"label[0,1.5;Sound]" ..
|
||||
"scrollbar[0,2;5.8,0.4;horizontal;sound;" .. volume[name].sound * 1000 .. "]" ..
|
||||
"button_exit[2,2.8;2,0.8;quit;Done]")
|
||||
end,
|
||||
"button_exit[2,2.8;2,0.8;quit;Done]"
|
||||
)
|
||||
end
|
||||
minetest.register_chatcommand("volume",{
|
||||
func = function(name)
|
||||
minetest.after(.1, show_formspec, name)
|
||||
end
|
||||
})
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
if rawget(_G, "inventory_plus") then
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
inventory_plus.register_button(player, "ambience_volume", "Volume")
|
||||
end)
|
||||
minetest.register_on_player_receive_fields(function(player, _, fields)
|
||||
if fields.volume then
|
||||
show_formspec(player:get_player_name())
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "ambience:volume" then
|
||||
return false
|
||||
end
|
||||
@ -639,12 +655,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
return true
|
||||
end)
|
||||
|
||||
if minetest.get_modpath("inventory_plus") then
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
inventory_plus.register_button(player, "ambience:volume", "Volume")
|
||||
end)
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("svol", {
|
||||
params = "<svol>",
|
||||
description = "set volume of sounds, default 1 normal volume.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user