From a37ba81545231e73fd2d5849a2861453e7058ed0 Mon Sep 17 00:00:00 2001 From: hkc Date: Sat, 14 Oct 2023 14:01:38 +0300 Subject: [PATCH] ignore self and proper bar size --- augment/modules/wh.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/augment/modules/wh.lua b/augment/modules/wh.lua index 93c94da..7be8023 100644 --- a/augment/modules/wh.lua +++ b/augment/modules/wh.lua @@ -18,10 +18,10 @@ local function entityBox(ent) local hp_rect_bg, hp_rect_fg if ent.health ~= nil then - hp_rect_bg = hpbar.addRectangle(-1, -0.25, 2, 0.25, options.hpbar.bg) - hp_rect_fg = hpbar.addRectangle(-1, -0.25, 0, 0.25, options.hpbar.fg) + hp_rect_bg = hpbar.addRectangle(0, 0, 100, 15, options.hpbar.bg) + hp_rect_fg = hpbar.addRectangle(0, 0, 0, 15, options.hpbar.fg) end - local hp_txt = hpbar.addText({ -1, -0.2 }, ent.name, options.hpbar.txt) + local hp_txt = hpbar.addText({ 0, 2 }, ent.name, options.hpbar.txt) return { _cube = cube, @@ -33,7 +33,7 @@ local function entityBox(ent) self._cube.setPosition(entity.x - 0.25, entity.y - 0.25, entity.z - 0.25) self._hpbar.setPosition(entity.x, entity.y + 0.5, entity.z) if self._hp_rect_fg ~= nil then - self._hp_rect_fg.setSize(2 * entity.health / entity.maxHealth, 0.25) + self._hp_rect_fg.setSize(100 * entity.health / entity.maxHealth, 15) end if entity.health ~= nil then self._hp_txt.setText(string.format("%s (%.1f/%.1f)", entity.name, entity.health, entity.maxHealth)) @@ -59,7 +59,9 @@ return function() end for uuid, entity in pairs(surroundings.entitiesByUUID) do - if cache[uuid] == nil then + if uuid == player.id then + -- nothing + elseif cache[uuid] == nil then cache[uuid] = entityBox(entity) else cache[uuid]:update(entity)