fix some codestyle issues in hudbars

This commit is contained in:
AFCMS 2021-05-26 16:42:12 +02:00
parent 190d5cad33
commit fd387a65af
1 changed files with 18 additions and 15 deletions

View File

@ -1,17 +1,22 @@
local S = minetest.get_translator("hudbars") local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local S = minetest.get_translator(modname)
local N = function(s) return s end local N = function(s) return s end
hb = {} local math = math
local table = table
hb.hudtables = {}
hb = {
hudtables = {},
-- number of registered HUD bars -- number of registered HUD bars
hb.hudbars_count = 0 hudbars_count = 0,
-- table which records which HUD bar slots have been “registered” so far; used for automatic positioning -- table which records which HUD bar slots have been “registered” so far; used for automatic positioning
hb.registered_slots = {} registered_slots = {},
settings = {},
hb.settings = {} -- Table which contains all players with active default HUD bars (only for internal use)
players = {},
}
function hb.load_setting(sname, stype, defaultval, valid_values) function hb.load_setting(sname, stype, defaultval, valid_values)
local sval local sval
@ -45,7 +50,8 @@ function hb.load_setting(sname, stype, defaultval, valid_values)
end end
-- Load default settings -- Load default settings
dofile(minetest.get_modpath("hudbars").."/default_settings.lua") dofile(modpath.."/default_settings.lua")
if minetest.get_modpath("mcl_experience") and not minetest.is_creative_enabled("") then if minetest.get_modpath("mcl_experience") and not minetest.is_creative_enabled("") then
-- reserve some space for experience bar: -- reserve some space for experience bar:
hb.settings.start_offset_left.y = hb.settings.start_offset_left.y - 20 hb.settings.start_offset_left.y = hb.settings.start_offset_left.y - 20
@ -85,9 +91,6 @@ local function make_label(format_string, format_string_config, label, start_valu
return ret return ret
end end
-- Table which contains all players with active default HUD bars (only for internal use)
hb.players = {}
function hb.value_to_barlength(value, max) function hb.value_to_barlength(value, max)
if max == 0 then if max == 0 then
return 0 return 0