Use 0.4.16 settings syntax

This breaks compability with Minetest 0.4.15, 0.4.14, 0.4.13 and 0.4.12
This commit is contained in:
Wuzzy 2017-06-20 16:38:52 +02:00
parent bd0641af52
commit e09eb8ab4f

@ -20,11 +20,11 @@ hb.settings = {}
function hb.load_setting(sname, stype, defaultval, valid_values)
local sval
if stype == "string" then
sval = minetest.setting_get(sname)
sval = minetest.settings:get(sname)
elseif stype == "bool" then
sval = minetest.setting_getbool(sname)
sval = minetest.settings:get_bool(sname)
elseif stype == "number" then
sval = tonumber(minetest.setting_get(sname))
sval = tonumber(minetest.settings:get(sname))
end
if sval ~= nil then
if valid_values ~= nil then
@ -83,7 +83,7 @@ hb.settings.forceload_default_hudbars = hb.load_setting("hudbars_forceload_defau
hb.settings.alignment_pattern = hb.load_setting("hudbars_alignment_pattern", "string", "zigzag", {"zigzag", "stack_up", "stack_down"})
hb.settings.autohide_breath = hb.load_setting("hudbars_autohide_breath", "bool", true)
local sorting = minetest.setting_get("hudbars_sorting")
local sorting = minetest.settings:get("hudbars_sorting")
if sorting ~= nil then
hb.settings.sorting = {}
hb.settings.sorting_reverse = {}
@ -464,7 +464,7 @@ function hb.get_hudbar_state(player, identifier)
end
--register built-in HUD bars
if minetest.setting_getbool("enable_damage") or hb.settings.forceload_default_hudbars then
if minetest.settings:get_bool("enable_damage") or hb.settings.forceload_default_hudbars then
hb.register_hudbar("health", 0xFFFFFF, S("Health"), { bar = "hudbars_bar_health.png", icon = "hudbars_icon_health.png", bgicon = "hudbars_bgicon_health.png" }, 20, 20, false)
hb.register_hudbar("breath", 0xFFFFFF, S("Breath"), { bar = "hudbars_bar_breath.png", icon = "hudbars_icon_breath.png", bgicon = "hudbars_bgicon_breath.png" }, 10, 10, true)
end
@ -478,9 +478,9 @@ end
local function custom_hud(player)
if minetest.setting_getbool("enable_damage") or hb.settings.forceload_default_hudbars then
if minetest.settings:get_bool("enable_damage") or hb.settings.forceload_default_hudbars then
local hide
if minetest.setting_getbool("enable_damage") then
if minetest.settings:get_bool("enable_damage") then
hide = false
else
hide = true
@ -500,7 +500,7 @@ end
-- update built-in HUD bars
local function update_hud(player)
if not player_exists(player) then return end
if minetest.setting_getbool("enable_damage") then
if minetest.settings:get_bool("enable_damage") then
if hb.settings.forceload_default_hudbars then
hb.unhide_hudbar(player, "health")
end
@ -550,7 +550,7 @@ minetest.register_globalstep(function(dtime)
if main_timer > hb.settings.tick or timer > 4 then
if main_timer > hb.settings.tick then main_timer = 0 end
-- only proceed if damage is enabled
if minetest.setting_getbool("enable_damage") or hb.settings.forceload_default_hudbars then
if minetest.settings:get_bool("enable_damage") or hb.settings.forceload_default_hudbars then
for _, player in pairs(hb.players) do
-- update all hud elements
update_hud(player)