From 4beec3566f3e48a628e0370bec67c9d8e485e3cb Mon Sep 17 00:00:00 2001 From: LeoTK <41605307+LeoTKBR@users.noreply.github.com> Date: Tue, 27 Aug 2024 23:15:47 -0300 Subject: [PATCH 1/2] #Fix OnLook - Monster return nil value --- data/scripts/eventcallbacks/player/on_look.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/data/scripts/eventcallbacks/player/on_look.lua b/data/scripts/eventcallbacks/player/on_look.lua index 022aebbcc36..37d76f99162 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" - if thing:isPlayer() and thing:getMaxMana() > 0 then - pId = string.format("Player ID: %i", thing:getGuid()) - str = string.format("%s, Mana: %d / %d", str, thing:getMana(), thing:getMaxMana()) - end - description = string.format(str, description, pId, thing:getHealth(), thing:getMaxHealth()) + local str, id = "%s\n%s\nHealth: %d / %d" + if thing:isPlayer() and thing:getMaxMana() > 0 then + 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, id, thing:getHealth(), thing:getMaxHealth()) end description = string.format("%s\nPosition: (%d, %d, %d)", description, position.x, position.y, position.z) From 01547b87df3c5cd8e093a400eef1cc2949b74097 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 28 Aug 2024 02:16:23 +0000 Subject: [PATCH 2/2] Lua code format - (Stylua) --- .../scripts/eventcallbacks/player/on_look.lua | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/data/scripts/eventcallbacks/player/on_look.lua b/data/scripts/eventcallbacks/player/on_look.lua index 37d76f99162..a2e625591c0 100644 --- a/data/scripts/eventcallbacks/player/on_look.lua +++ b/data/scripts/eventcallbacks/player/on_look.lua @@ -60,16 +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, id = "%s\n%s\nHealth: %d / %d" - if thing:isPlayer() and thing:getMaxMana() > 0 then - 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, id, thing:getHealth(), thing:getMaxHealth()) + local str, id = "%s\n%s\nHealth: %d / %d" + if thing:isPlayer() and thing:getMaxMana() > 0 then + 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, id, thing:getHealth(), thing:getMaxHealth()) end description = string.format("%s\nPosition: (%d, %d, %d)", description, position.x, position.y, position.z)