mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-11-05 01:50:25 +01:00
update soundset (calcul gain berore returning value)
update mod use soundset
This commit is contained in:
parent
986ee7e7ad
commit
5cb1581e77
|
@ -521,7 +521,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = cave
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -531,7 +531,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = cave_frequent
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -541,7 +541,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = swimming_frequent
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -551,7 +551,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = beach
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -561,7 +561,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = beach_frequent
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -571,7 +571,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = desert
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -581,7 +581,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = desert_frequent
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -591,7 +591,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = night
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -601,7 +601,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = night_frequent
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -611,7 +611,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = day
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -621,7 +621,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = day_frequent
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -631,7 +631,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = music
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -641,7 +641,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = flowing_water
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -651,7 +651,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = flowing_water2
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -661,7 +661,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = lava
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -671,7 +671,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = lava2
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -681,7 +681,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = water
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -691,7 +691,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = water_surface
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
played_on_start = false
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
|
@ -702,7 +702,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = water_frequent
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
-- minetest.chat_send_all("list.on_stop " .. list.on_stop )
|
||||
played_on_start = false
|
||||
end
|
||||
|
@ -717,7 +717,7 @@ local stop_sound = function(still_playing, player)
|
|||
-- minetest.chat_send_all("handler flying " )
|
||||
if list.on_stop ~= nil then
|
||||
-- minetest.chat_send_all("onstop flying" )
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
played_on_start = false
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
|
@ -728,7 +728,7 @@ local stop_sound = function(still_playing, player)
|
|||
local list = splashing_water
|
||||
if list.handler[player_name] ~= nil then
|
||||
if list.on_stop ~= nil then
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player_name, "ambience")})
|
||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=soundset.get_gain(player_name, "ambience")})
|
||||
end
|
||||
minetest.sound_stop(list.handler[player_name])
|
||||
list.handler[player_name] = nil
|
||||
|
@ -757,7 +757,7 @@ minetest.register_globalstep(function(dtime)
|
|||
-- end
|
||||
if ambience.on_start ~= nil and played_on_start == false then
|
||||
played_on_start = true
|
||||
minetest.sound_play(ambience.on_start, {to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player:get_player_name(), "ambience")})
|
||||
minetest.sound_play(ambience.on_start, {to_player=player:get_player_name(),gain=soundset.get_gain(player:get_player_name(), "ambience")})
|
||||
end
|
||||
-- minetest.chat_send_all("ambience: " ..ambience )
|
||||
-- if ambience.on_start ~= nil and played_on_start_flying == false then
|
||||
|
|
|
@ -310,7 +310,7 @@ function awards.give_achievement(name, award)
|
|||
|
||||
-- save playertable
|
||||
awards.save()
|
||||
minetest.sound_play("award_award_won", {to_player = name, gain = 0.5*soundset.get_gain(name,"other")})
|
||||
minetest.sound_play("award_award_won", {to_player = name, gain = soundset.get_gain(name,"other")})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ local function sound_play_all(dead)
|
|||
for _, p in ipairs(minetest.get_connected_players()) do
|
||||
local player_name = p:get_player_name()
|
||||
if player_name and player_name ~= dead then
|
||||
minetest.sound_play("death_messages_people_1",{to_player=player_name, gain=0.5*soundset.get_gain(player_name,"other")})
|
||||
minetest.sound_play("death_messages_people_1",{to_player=player_name, gain=soundset.get_gain(player_name,"other")})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -121,7 +121,7 @@ if RANDOM_MESSAGES == true then
|
|||
minetest.chat_send_all(death_message)
|
||||
irc:say(death_message)
|
||||
|
||||
minetest.sound_play(sounds[math.random(1,#sounds)],{to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player:get_player_name(),"other")})
|
||||
minetest.sound_play(sounds[math.random(1,#sounds)],{to_player=player:get_player_name(),gain=soundset.get_gain(player:get_player_name(),"other")})
|
||||
sound_play_all(player:get_player_name())
|
||||
end)
|
||||
|
||||
|
@ -145,7 +145,7 @@ else
|
|||
else
|
||||
minetest.chat_send_all(player_name .. " died.")
|
||||
end
|
||||
minetest.sound_play(sounds[math.random(1,#sounds)],{to_player=player:get_player_name(),gain=0.5*soundset.get_gain(player:get_player_name(),"other")})
|
||||
minetest.sound_play(sounds[math.random(1,#sounds)],{to_player=player:get_player_name(),gain=soundset.get_gain(player:get_player_name(),"other")})
|
||||
sound_play_all(player:get_player_name())
|
||||
end)
|
||||
end
|
||||
|
|
39
mods/soundset/README.md
Normal file
39
mods/soundset/README.md
Normal 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
63
mods/soundset/init.lua
Executable file → Normal 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>",
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue
Block a user