diff --git a/huds.lua b/huds.lua index e29c7bf..ba08487 100644 --- a/huds.lua +++ b/huds.lua @@ -1,6 +1,7 @@ local HUD_POSITION = { x = postool.hudPosX, y = postool.hudPosY } local HUD_ALIGNMENT = { x = 1, y = 0 } local HUD_SCALE = { x = 100, y = 100 } +local HUD_STATBAR_SIZE = { x = 160, y = 18 } -- hud id map (playername -> { playername = { tIDs = { hud-ids }, tb = { toggles }, ... ) postool.tHudDB = {} @@ -142,27 +143,18 @@ postool.rebuildHud = function(oPlayer) local bAdvTrains = postool.hasAdvancedTrains() local bMesecons = postool.hasMeseconsDebug() - local iID = tIDs.meseconsUsageBG + local iID = tIDs.meseconsUsageFG if tb[5] and bMesecons then if nil == iID then - tIDs.meseconsUsageBG = oPlayer:hud_add({ - hud_elem_type = 'statbar', - name = 'postoolMeseconsUsageBG', - position = tPosition, - offset = { x = 0, y = iY -23 }, - text = 'mesecons_use_bg.png', - scale = HUD_SCALE, - alignment = HUD_ALIGNMENT, - number = 3 - }) tIDs.meseconsUsageFG = oPlayer:hud_add({ hud_elem_type = 'statbar', name = 'postoolMeseconsUsageFG', position = tPosition, - offset = { x = 0, y = iY -23 }, + offset = { x = -2, y = iY - 27 }, text = 'mesecons_use_fg.png', scale = HUD_SCALE, + size = { x = 1, y = HUD_STATBAR_SIZE.y }, alignment = HUD_ALIGNMENT, number = 4 }) @@ -170,7 +162,7 @@ postool.rebuildHud = function(oPlayer) hud_elem_type = 'text', name = 'postoolMeseconsPenalty', position = tPosition, - offset = { x = 0, y = 0 }, + offset = { x = 0, y = -16 }, text = 'Initializing...', scale = HUD_SCALE, alignment = HUD_ALIGNMENT, @@ -183,7 +175,6 @@ postool.rebuildHud = function(oPlayer) elseif nil ~= iID then oPlayer:hud_remove(iID) - tIDs.meseconsUsageBG = nil oPlayer:hud_remove(tIDs.meseconsUsageFG) tIDs.meseconsUsageFG = nil oPlayer:hud_remove(tIDs.meseconsPenalty) @@ -359,8 +350,10 @@ postool.updateHudMesecons = function(oPlayer) oPlayer:hud_change(tIDs.meseconsPenalty, 'text', sPenalty) oPlayer:hud_change(tIDs.meseconsUsageFG, 'text', sTexture) -- give a minimum to show, so can see red penalty even when no usage - oPlayer:hud_change(tIDs.meseconsUsageFG, 'number', math.max(8, nPercent * 3)) - + oPlayer:hud_change(tIDs.meseconsUsageFG, 'size', { + x = math.max(8, .01 * nPercent * HUD_STATBAR_SIZE.x), + y = HUD_STATBAR_SIZE.y + math.floor(tCtx.penalty * 16) + }) end -- updateHudMesecons diff --git a/init.lua b/init.lua index 17bdeaf..74a7ab8 100644 --- a/init.lua +++ b/init.lua @@ -3,7 +3,7 @@ -- read the readme.md for more info on origin. -- safety check in case translation function does not exist -if not minetest.global_exists('S') then S = function(s) return s end end +local S = (minetest.global_exists('S') and S) or function(s) return s end --settings postool = { diff --git a/textures/mesecons_use_bg.png b/textures/mesecons_use_bg.png deleted file mode 100644 index 12bc461..0000000 Binary files a/textures/mesecons_use_bg.png and /dev/null differ