forked from mtcontrib/minetest_hudbars
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:
parent
bd0641af52
commit
e09eb8ab4f
18
init.lua
18
init.lua
|
@ -20,11 +20,11 @@ hb.settings = {}
|
||||||
function hb.load_setting(sname, stype, defaultval, valid_values)
|
function hb.load_setting(sname, stype, defaultval, valid_values)
|
||||||
local sval
|
local sval
|
||||||
if stype == "string" then
|
if stype == "string" then
|
||||||
sval = minetest.setting_get(sname)
|
sval = minetest.settings:get(sname)
|
||||||
elseif stype == "bool" then
|
elseif stype == "bool" then
|
||||||
sval = minetest.setting_getbool(sname)
|
sval = minetest.settings:get_bool(sname)
|
||||||
elseif stype == "number" then
|
elseif stype == "number" then
|
||||||
sval = tonumber(minetest.setting_get(sname))
|
sval = tonumber(minetest.settings:get(sname))
|
||||||
end
|
end
|
||||||
if sval ~= nil then
|
if sval ~= nil then
|
||||||
if valid_values ~= 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.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)
|
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
|
if sorting ~= nil then
|
||||||
hb.settings.sorting = {}
|
hb.settings.sorting = {}
|
||||||
hb.settings.sorting_reverse = {}
|
hb.settings.sorting_reverse = {}
|
||||||
|
@ -464,7 +464,7 @@ function hb.get_hudbar_state(player, identifier)
|
||||||
end
|
end
|
||||||
|
|
||||||
--register built-in HUD bars
|
--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("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)
|
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
|
end
|
||||||
|
@ -478,9 +478,9 @@ end
|
||||||
|
|
||||||
|
|
||||||
local function custom_hud(player)
|
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
|
local hide
|
||||||
if minetest.setting_getbool("enable_damage") then
|
if minetest.settings:get_bool("enable_damage") then
|
||||||
hide = false
|
hide = false
|
||||||
else
|
else
|
||||||
hide = true
|
hide = true
|
||||||
|
@ -500,7 +500,7 @@ end
|
||||||
-- update built-in HUD bars
|
-- update built-in HUD bars
|
||||||
local function update_hud(player)
|
local function update_hud(player)
|
||||||
if not player_exists(player) then return end
|
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
|
if hb.settings.forceload_default_hudbars then
|
||||||
hb.unhide_hudbar(player, "health")
|
hb.unhide_hudbar(player, "health")
|
||||||
end
|
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 or timer > 4 then
|
||||||
if main_timer > hb.settings.tick then main_timer = 0 end
|
if main_timer > hb.settings.tick then main_timer = 0 end
|
||||||
-- only proceed if damage is enabled
|
-- 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
|
for _, player in pairs(hb.players) do
|
||||||
-- update all hud elements
|
-- update all hud elements
|
||||||
update_hud(player)
|
update_hud(player)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user