diff options
author | rubenwardy <rw@rubenwardy.com> | 2019-08-06 19:30:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-06 19:30:18 +0100 |
commit | 8e757859d6a6bf6482480904e8485e9344e567ab (patch) | |
tree | 3304aa9393a753b85143389c6f6ffec990cfa12e /builtin/game/statbars.lua | |
parent | 8da35c22d1c8933090330b2f3c44b4cf2c6e6760 (diff) | |
download | minetest-8e757859d6a6bf6482480904e8485e9344e567ab.tar.gz minetest-8e757859d6a6bf6482480904e8485e9344e567ab.tar.bz2 minetest-8e757859d6a6bf6482480904e8485e9344e567ab.zip |
Add luacheck to check builtin (#7895)
Diffstat (limited to 'builtin/game/statbars.lua')
-rw-r--r-- | builtin/game/statbars.lua | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/builtin/game/statbars.lua b/builtin/game/statbars.lua index bb88356d5..46c947b60 100644 --- a/builtin/game/statbars.lua +++ b/builtin/game/statbars.lua @@ -1,8 +1,7 @@ -- cache setting local enable_damage = core.settings:get_bool("enable_damage") -local health_bar_definition = -{ +local health_bar_definition = { hud_elem_type = "statbar", position = { x=0.5, y=1 }, text = "heart.png", @@ -12,8 +11,7 @@ local health_bar_definition = offset = { x=(-10*24)-25, y=-(48+24+16)}, } -local breath_bar_definition = -{ +local breath_bar_definition = { hud_elem_type = "statbar", position = { x=0.5, y=1 }, text = "bubble.png", @@ -30,8 +28,8 @@ local function scaleToDefault(player, field) local current = player["get_" .. field](player) local nominal = core["PLAYER_MAX_".. field:upper() .. "_DEFAULT"] local max_display = math.max(nominal, - math.max(player:get_properties()[field .. "_max"], current)) - return current / max_display * nominal + math.max(player:get_properties()[field .. "_max"], current)) + return current / max_display * nominal end local function update_builtin_statbars(player) @@ -53,8 +51,8 @@ local function update_builtin_statbars(player) local immortal = player:get_armor_groups().immortal == 1 if flags.healthbar and enable_damage and not immortal then local number = scaleToDefault(player, "hp") - if hud.id_healthbar == nil then - local hud_def = table.copy(health_bar_definition) + if hud.id_healthbar == nil then + local hud_def = table.copy(health_bar_definition) hud_def.number = number hud.id_healthbar = player:hud_add(hud_def) else @@ -70,7 +68,7 @@ local function update_builtin_statbars(player) player:get_breath() < breath_max then local number = 2 * scaleToDefault(player, "breath") if hud.id_breathbar == nil then - local hud_def = table.copy(breath_bar_definition) + local hud_def = table.copy(breath_bar_definition) hud_def.number = number hud.id_breathbar = player:hud_add(hud_def) else @@ -125,14 +123,14 @@ local function player_event_handler(player,eventname) return false end -function core.hud_replace_builtin(name, definition) +function core.hud_replace_builtin(hud_name, definition) if type(definition) ~= "table" or definition.hud_elem_type ~= "statbar" then return false end - if name == "health" then + if hud_name == "health" then health_bar_definition = definition for name, ids in pairs(hud_ids) do @@ -146,7 +144,7 @@ function core.hud_replace_builtin(name, definition) return true end - if name == "breath" then + if hud_name == "breath" then breath_bar_definition = definition for name, ids in pairs(hud_ids) do |