1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-17 07:50:29 +01:00

fix crash soundset

fix crash soundset init.lua:111: attempt to index field '?'
This commit is contained in:
crabman77 2015-03-31 23:44:22 +02:00
parent a9449a276f
commit 91b0f25735

View File

@ -23,7 +23,6 @@ local function load_sounds_config()
sounds.gainplayers = minetest.deserialize(file:read("*all")) sounds.gainplayers = minetest.deserialize(file:read("*all"))
file:close() file:close()
end end
print("type: "..tostring(type(sounds.gainplayers)))
if sounds.gainplayers == nil or type(sounds.gainplayers) ~= "table" then if sounds.gainplayers == nil or type(sounds.gainplayers) ~= "table" then
sounds.gainplayers = {} sounds.gainplayers = {}
end end
@ -108,6 +107,7 @@ end
minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname == "soundset:settings" then if formname == "soundset:settings" then
local name = player:get_player_name() local name = player:get_player_name()
if not name then return end
local fmusic = sounds.tmp[name]["music"] local fmusic = sounds.tmp[name]["music"]
local fambience = sounds.tmp[name]["ambience"] local fambience = sounds.tmp[name]["ambience"]
if fields["abort"] == "Ok" then if fields["abort"] == "Ok" then
@ -168,6 +168,7 @@ if (minetest.get_modpath("unified_inventory")) then
tooltip = "sounds menu ", tooltip = "sounds menu ",
action = function(player) action = function(player)
local name = player:get_player_name() local name = player:get_player_name()
if not name then return end
on_show_settings(name, sounds.gainplayers[name]["music"], sounds.gainplayers[name]["ambience"]) on_show_settings(name, sounds.gainplayers[name]["music"], sounds.gainplayers[name]["ambience"])
end, end,
}) })
@ -178,6 +179,7 @@ minetest.register_chatcommand("soundset", {
description = "Display volume menu formspec", description = "Display volume menu formspec",
privs = {interact=true}, privs = {interact=true},
func = function(name, param) func = function(name, param)
if not name then return end
on_show_settings(name, sounds.gainplayers[name]["music"], sounds.gainplayers[name]["ambience"]) on_show_settings(name, sounds.gainplayers[name]["music"], sounds.gainplayers[name]["ambience"])
end end
}) })