1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-06-28 14:16:06 +02:00

update soundset (calcul gain berore returning value)

update mod use soundset
This commit is contained in:
2015-06-20 20:58:56 +02:00
parent 986ee7e7ad
commit 5cb1581e77
6 changed files with 89 additions and 76 deletions

39
mods/soundset/README.md Normal file
View File

@ -0,0 +1,39 @@
soundset MOD for MINETEST
========================
by Mg (@LeMagnesium) and @crabman77
YOUR mod can use THIS mod to have a volume that's adjustable by the player(s)
EXEMPLE
minetest.sound_play("music_file", {to_player=player:get_player_name(),gain=sounds.get_gain(player:get_player_name(), "music")})
OR
minetest.sound_play("mob_sound", {to_player=player:get_player_name(),gain=sounds.get_gain(player:get_player_name(), "mobs")})
OR
minetest.sound_play("wind_sound", {to_player=player:get_player_name(),gain=sounds.get_gain(player:get_player_name(), "ambience")})
commandchat
/soundset : display menu
/soundsetg : display player config
/soundsets <music|ambience|mobs|other> <number> : set volume
Licenses images: Author:mikhog http://opengameart.org/content/play-pause-mute-and-unmute-buttons CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
0.1 - Initial Release
0.2 - change default volume to 50, add serialise|deserialise to read|write config file
0.3 - add menu setting and button for unified_inventory and chatcommand to display menu

63
mods/soundset/init.lua Executable file → Normal file
View File

@ -76,13 +76,29 @@ soundset.get_gain = function(name, sound_type)
if gain == nil then
return 1
end
return gain/50
return gain/100
end
local inc = function(value)
value = value + 5
if value > 100 then
value = 100
end
return value
end
local dec = function(value)
value = value - 5
if value < 0 then
value = 0
end
return value
end
local formspec = "size[6,6]"..
"label[2,0;Sound Menu]"..
"label[0.3,1.2;MUSIC]"..
"label[0,1.2;MUSIC]"..
"image_button[1.6,1;1,1;soundset_dec.png;vmusic;-]"..
"label[2.7,1.2;%s]"..
"image_button[3.5,1;1,1;soundset_inc.png;vmusic;+]"..
@ -129,47 +145,17 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
soundset.tmp[name] = nil
return
elseif fields["vmusic"] == "+" then
if fmusic < 100 then
fmusic = fmusic +5
if fmusic > 100 then
fmusic = 100
end
end
fmusic = inc(fmusic)
elseif fields["vmusic"] == "-" then
if fmusic > 0 then
fmusic = fmusic -5
if fmusic < 0 then
fmusic = 0
end
end
fmusic = dec(fmusic)
elseif fields["vambience"] == "+" then
if fambience < 100 then
fambience = fambience +5
if fambience > 100 then
fambience = 100
end
end
fambience = inc(fambience)
elseif fields["vambience"] == "-" then
if fambience > 0 then
fambience = fambience -5
if fambience < 0 then
fambience = 0
end
end
fambience = dec(fambience)
elseif fields["vother"] == "+" then
if fother < 100 then
fother = fother +5
if fother > 100 then
fother = 100
end
end
fother = inc(fother)
elseif fields["vother"] == "-" then
if fother > 0 then
fother = fother -5
if fother < 0 then
fother = 0
end
end
fother = dec(fother)
elseif fields["quit"] == "true" then
soundset.tmp[name] = nil
return
@ -206,7 +192,6 @@ minetest.register_chatcommand("soundset", {
})
minetest.register_chatcommand("soundsets", {
params = "<music|ambience|mobs|other> <number>",
description = "Set volume sound <music|ambience|mobs|other>",

View File

@ -1,11 +0,0 @@
-= soundset-MOD for MINETEST =-
by LeMagnesium and crabman77
YOUR mod can use THIS mod to have a volume that's adjustable by the player(s)
0.1 - Initial Release
0.2 - add menu setting and button for unified_inventory and chatcommand to display menu
Licenses images: Author:mikhog http://opengameart.org/content/play-pause-mute-and-unmute-buttons CC0 1.0 Universal (CC0 1.0) Public Domain Dedication