From 72917d4cb35fd3a1bc571950af3a1af853343545 Mon Sep 17 00:00:00 2001 From: LeoTK <41605307+LeoTKBR@users.noreply.github.com> Date: Mon, 14 Oct 2024 10:40:56 -0300 Subject: [PATCH] fix: onLook nil value (#2856) Showing nil on look monsters and npcs. --- data/scripts/eventcallbacks/player/on_look.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/data/scripts/eventcallbacks/player/on_look.lua b/data/scripts/eventcallbacks/player/on_look.lua index 6b4be92553a..851cd9b707f 100644 --- a/data/scripts/eventcallbacks/player/on_look.lua +++ b/data/scripts/eventcallbacks/player/on_look.lua @@ -60,12 +60,16 @@ function callback.playerOnLook(player, thing, position, distance) description = string.format("%s\nDecays to: %d", description, decayId) end elseif thing:isCreature() then - local str, pId = "%s\n%s\nHealth: %d / %d" + local str, id = "%s\n%s\nHealth: %d / %d" if thing:isPlayer() and thing:getMaxMana() > 0 then - pId = string.format("Player ID: %i", thing:getGuid()) + id = string.format("Player ID: %i", thing:getGuid()) str = string.format("%s, Mana: %d / %d", str, thing:getMana(), thing:getMaxMana()) + elseif thing:isMonster() then + id = string.format("Monster ID: %i", thing:getId()) + elseif thing:isNpc() then + id = string.format("NPC ID: %i", thing:getId()) end - description = string.format(str, description, pId, thing:getHealth(), thing:getMaxHealth()) + description = string.format(str, description, id, thing:getHealth(), thing:getMaxHealth()) end description = string.format("%s\nPosition: (%d, %d, %d)", description, position.x, position.y, position.z)