From 4e33448f1ce31d21d151f6a32ad23cb5ca565e12 Mon Sep 17 00:00:00 2001 From: brightrim Date: Tue, 26 Nov 2024 17:22:12 +0100 Subject: [PATCH] Add destination for npc books --- magic/arcane/spatial.lua | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/magic/arcane/spatial.lua b/magic/arcane/spatial.lua index abd4ec952..b11804df1 100644 --- a/magic/arcane/spatial.lua +++ b/magic/arcane/spatial.lua @@ -30,6 +30,18 @@ local castTexts = texts.castSpellTexts local portalSpots = texts.portalSpots local myTexts = texts.spatialTexts +local function findSpotNameBasedOnCoord(coordinates) + + for _, spot in pairs(texts.portalSpots) do + if spot.location == coordinates then + return spot.nameEn, spot.nameDe + end + end + + return false +end + + function M.attunedSpotsToQuestprogress(attunedSpots) if attunedSpots < 2^31 then return attunedSpots @@ -307,7 +319,26 @@ local function getDestinationText(book) local destinationDe = book:getData("destinationDe") if common.IsNilOrEmpty(destinationDe) then - return "", "" -- No destination info for NPC sold books as it is written on them + + local Z = tonumber(book:getData("destinationCoordsZ")) + local X = tonumber(book:getData("destinationCoordsX")) + local Y = tonumber(book:getData("destinationCoordsZ")) + + local coordinates = false + + if not common.IsNilOrEmpty(Z) and not common.IsNilOrEmpty(X) and not common.IsNilOrEmpty(Y) then + position(X, Y, Z) + end + + if coordinates then + destinationEn, destinationDe = findSpotNameBasedOnCoord(coordinates) + end + + if common.IsNilOrEmpty(destinationDe) then + -- The coordinates do not match any mage attuned location + destinationEn = "Unknown" + destinationDe = "Unbekannt" + end end local prefixEn = "Destination: "