From 66e73ddf31a4d1b3acccd7b162404c56348f9ead Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Fri, 8 Sep 2023 20:33:02 +0100 Subject: [PATCH] tweak for 5.0 --- init.lua | 36 +++++++++--------------------------- mod.conf | 3 ++- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/init.lua b/init.lua index 0696926..022ccea 100644 --- a/init.lua +++ b/init.lua @@ -11,7 +11,6 @@ local playing = {} local sound_sets = {} -- all the sounds and their settings local sound_set_order = {} -- needed because pairs loops randomly through tables local set_nodes = {} -- all the nodes needed for sets -local is_50 = minetest.has_feature("object_use_texture_alpha") -- add set to list @@ -100,17 +99,10 @@ minetest.register_on_joinplayer(function(player) playing[name] = {music = -1} local mvol, svol + local meta = player:get_meta() - if is_50 then - - local meta = player:get_meta() - - mvol = meta:get_string("ambience.mvol") - svol = meta:get_string("ambience.svol") - else - mvol = player:get_attribute("ambience.mvol") - svol = player:get_attribute("ambience.svol") - end + mvol = meta:get_string("ambience.mvol") + svol = meta:get_string("ambience.svol") mvol = tonumber(mvol) or MUSICVOLUME svol = tonumber(svol) or SOUNDVOLUME @@ -326,15 +318,10 @@ minetest.register_chatcommand("svol", { if svol < 0.1 then svol = 0.1 end if svol > 1.0 then svol = 1.0 end - if is_50 then + local player = minetest.get_player_by_name(name) + local meta = player:get_meta() - local player = minetest.get_player_by_name(name) - local meta = player:get_meta() - - meta:set_string("ambience.svol", svol) - else - player:set_attribute("ambience.svol", svol) - end + meta:set_string("ambience.svol", svol) playing[name].svol = svol @@ -365,15 +352,10 @@ minetest.register_chatcommand("mvol", { if mvol < 0 then mvol = 0 end if mvol > 1.0 then mvol = 1.0 end - if is_50 then + local player = minetest.get_player_by_name(name) + local meta = player:get_meta() - local player = minetest.get_player_by_name(name) - local meta = player:get_meta() - - meta:set_string("ambience.mvol", mvol) - else - player:set_attribute("ambience.mvol", mvol) - end + meta:set_string("ambience.mvol", mvol) playing[name].mvol = mvol diff --git a/mod.conf b/mod.conf index de39c52..45e69fe 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,5 @@ name = ambience +description = Adds realistic sound effects into your world. depends = default optional_depends = fire, playerplus -description = Adds realistic sound effects into your world. +min_minetest_version = 5.0