From 6b511f6b68aa8b87bbda2cce001a7d04c371010e Mon Sep 17 00:00:00 2001 From: xomachine Date: Mon, 5 Mar 2018 16:16:50 +0300 Subject: [PATCH] Fixed npc disappear when they can not see player while speaking --- .../others/scripts/quest/text_generation.lua | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/translations/others/scripts/quest/text_generation.lua b/translations/others/scripts/quest/text_generation.lua index a965b5e95..0c0986529 100644 --- a/translations/others/scripts/quest/text_generation.lua +++ b/translations/others/scripts/quest/text_generation.lua @@ -102,22 +102,22 @@ function QuestTextGenerator:generateExtraTags() local mindist = 100000 local pl = nil for idx, pid in pairs(world.players()) do - if entity.entityInSight(pid) then - local dstv = entity.distanceToEntity(pid) - local dst = dstv[1] * dstv[1] + dstv[2] * dstv[2] - if dst < mindist then - mindist = dst - pl = pid - end + local dstv = entity.distanceToEntity(pid) + local dst = dstv[1] * dstv[1] + dstv[2] * dstv[2] + if dst < mindist then + mindist = dst + pl = pid end end - self.parameters["player"] = { - gender = world.entityGender(pl), - species = world.entitySpecies(pl), - name = world.entityName(pl), - type = "entity", - id = function() return pl end - } + if pl then + self.parameters["player"] = { + gender = world.entityGender(pl), + species = world.entitySpecies(pl), + name = world.entityName(pl), + type = "entity", + id = function() return pl end + } + end end end