Fix setting data type issues
This commit is contained in:
parent
67c1a38987
commit
30633146ee
@ -53,9 +53,16 @@ end
|
|||||||
|
|
||||||
function ctf.setting(name)
|
function ctf.setting(name)
|
||||||
local set = minetest.setting_get("ctf_"..name)
|
local set = minetest.setting_get("ctf_"..name)
|
||||||
|
local dset = ctf._defsettings[name]
|
||||||
if set ~= nil then
|
if set ~= nil then
|
||||||
|
if type(dset) == "number" then
|
||||||
|
return tonumber(set)
|
||||||
|
elseif type(dset) == "bool" then
|
||||||
|
return minetest.is_yes(set)
|
||||||
|
else
|
||||||
return set
|
return set
|
||||||
elseif ctf._defsettings[name] ~= nil then
|
end
|
||||||
|
elseif dset ~= nil then
|
||||||
return ctf._defsettings[name]
|
return ctf._defsettings[name]
|
||||||
else
|
else
|
||||||
print("[CaptureTheFlag] Setting "..name.." not found!")
|
print("[CaptureTheFlag] Setting "..name.." not found!")
|
||||||
@ -63,11 +70,6 @@ function ctf.setting(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ctf.setting_bool(name)
|
|
||||||
local set = ctf.setting(name)
|
|
||||||
return minetest.is_yes(set)
|
|
||||||
end
|
|
||||||
|
|
||||||
function ctf.load()
|
function ctf.load()
|
||||||
local file = io.open(minetest.get_worldpath().."/ctf.txt", "r")
|
local file = io.open(minetest.get_worldpath().."/ctf.txt", "r")
|
||||||
if file then
|
if file then
|
||||||
@ -167,7 +169,7 @@ function ctf.join(name, team, force)
|
|||||||
if ctf.add_user(team, player) == true then
|
if ctf.add_user(team, player) == true then
|
||||||
minetest.chat_send_all(name.." has joined team "..team)
|
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))
|
ctf.hud.update(minetest.get_player_by_name(name))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ local count = 0
|
|||||||
function ctf.hud.updateAll()
|
function ctf.hud.updateAll()
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
if not ctf.setting_bool("hud") then
|
if not ctf.setting("hud") then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user