Fix setting data type issues

master
rubenwardy 2014-12-29 19:58:11 +00:00
parent 67c1a38987
commit 30633146ee
2 changed files with 11 additions and 9 deletions

View File

@ -53,9 +53,16 @@ end
function ctf.setting(name)
local set = minetest.setting_get("ctf_"..name)
local dset = ctf._defsettings[name]
if set ~= nil then
return set
elseif ctf._defsettings[name] ~= nil then
if type(dset) == "number" then
return tonumber(set)
elseif type(dset) == "bool" then
return minetest.is_yes(set)
else
return set
end
elseif dset ~= nil then
return ctf._defsettings[name]
else
print("[CaptureTheFlag] Setting "..name.." not found!")
@ -63,11 +70,6 @@ function ctf.setting(name)
end
end
function ctf.setting_bool(name)
local set = ctf.setting(name)
return minetest.is_yes(set)
end
function ctf.load()
local file = io.open(minetest.get_worldpath().."/ctf.txt", "r")
if file then
@ -167,7 +169,7 @@ function ctf.join(name, team, force)
if ctf.add_user(team, player) == true then
minetest.chat_send_all(name.." has joined team "..team)
if ctf.setting_bool("hud") then
if ctf.setting("hud") then
ctf.hud.update(minetest.get_player_by_name(name))
end

View File

@ -93,7 +93,7 @@ local count = 0
function ctf.hud.updateAll()
count = 0
if not ctf.setting_bool("hud") then
if not ctf.setting("hud") then
return
end