Thread Tools Display Modes
11/13/14, 12:16 PM   #1
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Problem with Destinations

I am stuck on a problem trying to make Destinations compatible with MiniMap by Fyrakin.
My "Semi-Real" pins was made in a very dirty way earlier.
Now I want to add them correctly like this (short example):
Lua Code:
  1. LMP:AddPinType(PINS_REALUNKNOWNQUESTHUB, MapCallback_unknown, nil, pinLayout_RealUnknownQuestHub, pinTooltipCreator)
  2.     local pinLayout_RealUnknownCrafting = {
  3.         level = pinTextureLevelUnknown,
  4.         texture = pinTextures.unknownrealpins[9],
  5.         size = pinTextureSizeUnknown,
  6.     }
  7.     LMP:AddPinType(PINS_REALUNKNOWNCRAFTING, MapCallback_unknown, nil, pinLayout_RealUnknownCrafting, pinTooltipCreator)
  8.     local pinLayout_RealUnknownSoloDungeon = {
  9.         level = pinTextureLevelUnknown,
  10.         texture = pinTextures.unknownrealpins[10],
  11.         size = pinTextureSizeUnknown,
  12.     }
The poiTypeId sets the pin type used below, ending with creating the pins.
Lua Code:
  1. if poiTypeId == 1 then
  2.                         pinType = PINS_REALUNKNOWNWAYSHRINE
  3.                         local data = GuildTraderDataStore[GetCurrentMapZoneIndex()]
  4.                         if not data then return end
  5.                         for _, pinData in ipairs(data) do
  6.                             local ID = pinData[GuildTraderDataIndex.ID]
  7.                             if ID == 1 then
  8.                                 local WAYSHRINE = pinData[GuildTraderDataIndex.WAYSHRINE]
  9.                                 if WAYSHRINE == objectiveName then
  10.                                     table.insert(pinTag, 3, zo_strformat("|c666666<<t:1>>|r", GetString(POITYPE_GUILDTRADERS)))
  11.                                     pinType = PINS_REALUNKNOWNWAYSHRINETRADER
  12.                                 end
  13.                             end
  14.                         end
  15.                     elseif poiTypeId == 2 then
  16.                         pinType = PINS_REALUNKNOWNAOI
  17.                     elseif poiTypeId == 3 and zoneIndex ~= 353 then
  18.                         pinType = PINS_REALUNKNOWNPUBLICDUNGEON
  19.                     elseif poiTypeId == 3 and zoneIndex == 353 then
  20.                         pinType = PINS_REALUNKNOWNPUBLICDUNGEON2
  21.                     elseif poiTypeId == 4 then
  22.                         pinType = PINS_REALUNKNOWNMUNDUS
  23.                     elseif poiTypeId == 5 then
  24.                         pinType = PINS_REALUNKNOWNDOLMEN
  25.                     elseif poiTypeId == 6 then
  26.                         pinType = PINS_REALUNKNOWNGROUPBOSS
  27.                     elseif poiTypeId == 7 then
  28.                         pinType = PINS_REALUNKNOWNGROUPDUNGEON
  29.                     elseif poiTypeId == 8 then
  30.                         pinType = PINS_REALUNKNOWNQUESTHUB
  31.                     elseif poiTypeId == 9 then
  32.                         pinType = PINS_REALUNKNOWNCRAFTING
  33.                     elseif poiTypeId == 10 then
  34.                         pinType = PINS_REALUNKNOWNSOLODUNGEON
  35.                     elseif poiTypeId == 11 then
  36.                         pinType = PINS_REALUNKNOWNGROUPEVENT
  37.                     elseif poiTypeId == 12 then
  38.                         pinType = PINS_REALUNKNOWNGROUPDELVE
  39.                     elseif poiTypeId == 13 then
  40.                         pinType = PINS_REALUNKNOWNTRIAL
  41.                     elseif poiTypeId == 14 then
  42.                         pinType = PINS_REALUNKNOWNGUILDTRADER
  43.                     elseif poiTypeId == 22 then
  44.                         pinType = PINS_REALUNKNOWN
  45.                     end
  46.                 end
  47.                 LMP:CreatePin(pinType, pinTag, normalizedX, normalizedY)
The pins are shown correctly , but (I assume) as they all use the same pinTooltipCreator, then I get the tag on each pin shown multiple times, like this:

It is ONLY the unknown pins that do this and ONLY those using my "Semi_Real" pins.
Any help will be appreciated

Last edited by SnowmanDK : 11/13/14 at 09:11 PM.
  Reply With Quote
11/13/14, 02:48 PM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Destinations addon uses pinTag for tooltips - pinTag contains table (array) of strings, each string is one text line on the tooltip. In your code is nothing what adds text to the tooltip. Can you post whole function?
  Reply With Quote
11/13/14, 02:52 PM   #3
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Originally Posted by Garkin View Post
Destinations addon uses pinTag for tooltips - pinTag contains table (array) of strings, each string is one text line on the tooltip. In your code is nothing what adds text to the tooltip. Can you post whole function?
Sorry
Here is the entire function:
Lua Code:
  1. local function CreateMapPins(pinType, known)
  2.     if not LMP:IsEnabled(pinType) or (GetMapType() > MAPTYPE_ZONE) then return end
  3.     local zoneIndex = GetCurrentMapZoneIndex()
  4.     local data = MapDataStore[GetCurrentMapZoneIndex()]
  5.     for i = 1, GetNumPOIs(zoneIndex) do
  6.         local normalizedX, normalizedY, poiType, icon = GetPOIMapInfo(zoneIndex, i)
  7.         local unknown = (poiType == MAP_PIN_TYPE_INVALID)
  8.         local objectiveName = GetPOIInfo(zoneIndex, i)
  9.         local poiTypeId = 22
  10.         local poiTypeName
  11.         local pinTag
  12.         if data then
  13.             for _, pinLookup in ipairs(data) do
  14.                 if pinLookup[1] == objectiveName then
  15.                     poiTypeId = pinLookup[2]
  16.                     break
  17.                 end
  18.             end
  19.         end
  20.         poiTypeName = GetPoiTypeName(poiTypeId)
  21.         if unknown then
  22.             if not known then
  23.                 pinTag = {zo_strformat("|c0099CC<<t:1>>|r", objectiveName), zo_strformat("[<<t:1>>]", poiTypeName)}
  24.                 if localLanguage ~= "en" and savedVariables.filters[PINS_ADD_ENGLISH] == true then
  25.                     if englishPOINames[zoneIndex] and englishPOINames[zoneIndex][i] then
  26.                         table.insert(pinTag, 2, zo_strformat("|c006688<<t:1>>|r", englishPOINames[zoneIndex][i])) --insert english name as a second tooltip line
  27.                     end
  28.                 end
  29.                 local index = savedVariables.pinTextureUnknown.type
  30.                 if index == 7 then
  31.                     if poiTypeId == 1 then
  32.                         pinType = PINS_REALUNKNOWNWAYSHRINE
  33.                         local data = GuildTraderDataStore[GetCurrentMapZoneIndex()]
  34.                         if not data then return end
  35.                         for _, pinData in ipairs(data) do
  36.                             local ID = pinData[GuildTraderDataIndex.ID]
  37.                             if ID == 1 then
  38.                                 local WAYSHRINE = pinData[GuildTraderDataIndex.WAYSHRINE]
  39.                                 if WAYSHRINE == objectiveName then
  40.                                     table.insert(pinTag, 3, zo_strformat("|c666666<<t:1>>|r", GetString(POITYPE_GUILDTRADERS)))
  41.                                     pinType = PINS_REALUNKNOWNWAYSHRINETRADER
  42.                                 end
  43.                             end
  44.                         end
  45.                     elseif poiTypeId == 2 then
  46.                         pinType = PINS_REALUNKNOWNAOI
  47.                     elseif poiTypeId == 3 and zoneIndex ~= 353 then
  48.                         pinType = PINS_REALUNKNOWNPUBLICDUNGEON
  49.                     elseif poiTypeId == 3 and zoneIndex == 353 then
  50.                         pinType = PINS_REALUNKNOWNPUBLICDUNGEON2
  51.                     elseif poiTypeId == 4 then
  52.                         pinType = PINS_REALUNKNOWNMUNDUS
  53.                     elseif poiTypeId == 5 then
  54.                         pinType = PINS_REALUNKNOWNDOLMEN
  55.                     elseif poiTypeId == 6 then
  56.                         pinType = PINS_REALUNKNOWNGROUPBOSS
  57.                     elseif poiTypeId == 7 then
  58.                         pinType = PINS_REALUNKNOWNGROUPDUNGEON
  59.                     elseif poiTypeId == 8 then
  60.                         pinType = PINS_REALUNKNOWNQUESTHUB
  61.                     elseif poiTypeId == 9 then
  62.                         pinType = PINS_REALUNKNOWNCRAFTING
  63.                     elseif poiTypeId == 10 then
  64.                         pinType = PINS_REALUNKNOWNSOLODUNGEON
  65.                     elseif poiTypeId == 11 then
  66.                         pinType = PINS_REALUNKNOWNGROUPEVENT
  67.                     elseif poiTypeId == 12 then
  68.                         pinType = PINS_REALUNKNOWNGROUPDELVE
  69.                     elseif poiTypeId == 13 then
  70.                         pinType = PINS_REALUNKNOWNTRIAL
  71.                     elseif poiTypeId == 14 then
  72.                         pinType = PINS_REALUNKNOWNGUILDTRADER
  73.                     elseif poiTypeId == 22 then
  74.                         pinType = PINS_REALUNKNOWN
  75.                     end
  76.                 end
  77.                 LMP:CreatePin(pinType, pinTag, normalizedX, normalizedY)
  78.                 if index == 7 then
  79.                     pinType = PINS_UNKNOWN
  80.                 end
  81.             end
  82.         else
  83.             if known then
  84.                 if GetMapType() ~= 1 then
  85.                     pinTag = {zo_strformat("<<t:1>>", objectiveName), zo_strformat("[<<t:1>>]", poiTypeName)}
  86.                     if localLanguage ~= "en" and savedVariables.filters[PINS_ADD_ENGLISH] == true then
  87.                         if englishPOINames[zoneIndex] and englishPOINames[zoneIndex][i] then
  88.                             if poiTypeName == "Oratoire" or poiTypeName == "Wegschrein" then
  89.                                 pinTag = {zo_strformat("|c777755<<t:1>>|r", englishPOINames[zoneIndex][i]), zo_strformat("[<<t:1>>]", poiTypeName)}
  90.                             else
  91.                                 table.insert(pinTag, 2, zo_strformat("|c777755<<t:1>>|r", englishPOINames[zoneIndex][i])) --insert english name as a second tooltip line
  92.                             end
  93.                         end
  94.                     end
  95.                     if poiTypeName ~= "Wayshrine" then
  96.                         LMP:CreatePin(pinType, pinTag, normalizedX, normalizedY)
  97.                     end
  98.                 end
  99.             end
  100.         end
  101.     end
  102. end

Last edited by SnowmanDK : 11/13/14 at 02:54 PM.
  Reply With Quote
11/13/14, 03:05 PM   #4
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
I do not see anything what can add multiple lines to the tooltip. Are you sure that CreateMapPins function is called only once per zone? If you call CreateMapPins function multiple times, you will have lots of pins at the same place. In this case tooltip shows text for all pins under the mouse cursor.
  Reply With Quote
11/13/14, 03:26 PM   #5
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Originally Posted by Garkin View Post
I do not see anything what can add multiple lines to the tooltip. Are you sure that CreateMapPins function is called only once per zone? If you call CreateMapPins function multiple times, you will have lots of pins at the same place. In this case tooltip shows text for all pins under the mouse cursor.
I guess the cause is that it makes a call for every LMP:AddPinType I do during OnLoad, but I don't know another way of adding the pintypes:
Lua Code:
  1. local pinLayout_RealUnknownWayshrine = {
  2.         level = pinTextureLevelUnknown,
  3.         texture = pinTextures.unknownrealpins[1],
  4.         size = pinTextureSizeUnknown,
  5.     }
  6.     LMP:AddPinType(PINS_REALUNKNOWNWAYSHRINE, MapCallback_unknown, nil, pinLayout_RealUnknownWayshrine, pinTooltipCreator)
  7.     local pinLayout_RealUnknownAOI = {
  8.         level = pinTextureLevelUnknown,
  9.         texture = pinTextures.unknownrealpins[2],
  10.         size = pinTextureSizeUnknown,
  11.     }
  12.     LMP:AddPinType(PINS_REALUNKNOWNAOI, MapCallback_unknown, nil, pinLayout_RealUnknownAOI, pinTooltipCreator)
  13.     local pinLayout_RealUnknownPublicDungeon = {
  14.         level = pinTextureLevelUnknown,
  15.         texture = pinTextures.unknownrealpins[3],
  16.         size = pinTextureSizeUnknown,
  17.     }
  18.     LMP:AddPinType(PINS_REALUNKNOWNPUBLICDUNGEON, MapCallback_unknown, nil, pinLayout_RealUnknownPublicDungeon, pinTooltipCreator)
  19.     local pinLayout_RealUnknownMundus = {
  20.         level = pinTextureLevelUnknown,
  21.         texture = pinTextures.unknownrealpins[4],
  22.         size = pinTextureSizeUnknown,
  23.     }
  24.     LMP:AddPinType(PINS_REALUNKNOWNMUNDUS, MapCallback_unknown, nil, pinLayout_RealUnknownMundus, pinTooltipCreator)
  25.     local pinLayout_RealUnknownDolmen = {
  26.         level = pinTextureLevelUnknown,
  27.         texture = pinTextures.unknownrealpins[5],
  28.         size = pinTextureSizeUnknown,
  29.     }
  30.     LMP:AddPinType(PINS_REALUNKNOWNDOLMEN, MapCallback_unknown, nil, pinLayout_RealUnknownDolmen, pinTooltipCreator)
  31.     local pinLayout_RealUnknownGroupBoss = {
  32.         level = pinTextureLevelUnknown,
  33.         texture = pinTextures.unknownrealpins[6],
  34.         size = pinTextureSizeUnknown,
  35.     }
  36.     LMP:AddPinType(PINS_REALUNKNOWNGROUPBOSS, MapCallback_unknown, nil, pinLayout_RealUnknownGroupBoss, pinTooltipCreator)
  37.     local pinLayout_RealUnknownGroupDungeon = {
  38.         level = pinTextureLevelUnknown,
  39.         texture = pinTextures.unknownrealpins[7],
  40.         size = pinTextureSizeUnknown,
  41.     }
  42.     LMP:AddPinType(PINS_REALUNKNOWNGROUPDUNGEON, MapCallback_unknown, nil, pinLayout_RealUnknownGroupDungeon, pinTooltipCreator)
  43.     local pinLayout_RealUnknownQuestHub = {
  44.         level = pinTextureLevelUnknown,
  45.         texture = pinTextures.unknownrealpins[8],
  46.         size = pinTextureSizeUnknown,
  47.     }
  48.     LMP:AddPinType(PINS_REALUNKNOWNQUESTHUB, MapCallback_unknown, nil, pinLayout_RealUnknownQuestHub, pinTooltipCreator)
  49.     local pinLayout_RealUnknownCrafting = {
  50.         level = pinTextureLevelUnknown,
  51.         texture = pinTextures.unknownrealpins[9],
  52.         size = pinTextureSizeUnknown,
  53.     }
  54.     LMP:AddPinType(PINS_REALUNKNOWNCRAFTING, MapCallback_unknown, nil, pinLayout_RealUnknownCrafting, pinTooltipCreator)
  55.     local pinLayout_RealUnknownSoloDungeon = {
  56.         level = pinTextureLevelUnknown,
  57.         texture = pinTextures.unknownrealpins[10],
  58.         size = pinTextureSizeUnknown,
  59.     }
  60.     LMP:AddPinType(PINS_REALUNKNOWNSOLODUNGEON, MapCallback_unknown, nil, pinLayout_RealUnknownSoloDungeon, pinTooltipCreator)
  61.     local pinLayout_RealUnknownGroupEvent = {
  62.         level = pinTextureLevelUnknown,
  63.         texture = pinTextures.unknownrealpins[11],
  64.         size = pinTextureSizeUnknown,
  65.     }
  66.     LMP:AddPinType(PINS_REALUNKNOWNGROUPEVENT, MapCallback_unknown, nil, pinLayout_RealUnknownGroupEvent, pinTooltipCreator)
  67.  
  68.     local pinLayout_RealUnknownGroupDelve = {
  69.         level = pinTextureLevelUnknown,
  70.         texture = pinTextures.unknownrealpins[12],
  71.         size = pinTextureSizeUnknown,
  72.     }
  73.     LMP:AddPinType(PINS_REALUNKNOWNGROUPDELVE, MapCallback_unknown, nil, pinLayout_RealUnknownGroupDelve, pinTooltipCreator)
  74.     local pinLayout_RealUnknownTrial = {
  75.         level = pinTextureLevelUnknown,
  76.         texture = pinTextures.unknownrealpins[13],
  77.         size = pinTextureSizeUnknown,
  78.     }
  79.     LMP:AddPinType(PINS_REALUNKNOWNTRIAL, MapCallback_unknown, nil, pinLayout_RealUnknownTrial, pinTooltipCreator)
  80.     local pinLayout_RealUnknownGuildTrader = {
  81.         level = pinTextureLevelUnknown,
  82.         texture = pinTextures.unknownrealpins[14],
  83.         size = pinTextureSizeUnknown,
  84.     }
  85.     LMP:AddPinType(PINS_REALUNKNOWNGUILDTRADER, MapCallback_unknown, nil, pinLayout_RealUnknownGuildTrader, pinTooltipCreator)
  86.     local pinLayout_RealUnknownWayshrineTrader = {
  87.         level = pinTextureLevelUnknown,
  88.         texture = pinTextures.unknownrealpins[15],
  89.         size = pinTextureSizeUnknown,
  90.     }
  91.     LMP:AddPinType(PINS_REALUNKNOWNWAYSHRINETRADER, MapCallback_unknown, nil, pinLayout_RealUnknownWayshrineTrader, pinTooltipCreator)
  92.     local pinLayout_RealUnknownPublicDungeon2 = {
  93.         level = pinTextureLevelUnknown,
  94.         texture = pinTextures.unknownrealpins[16],
  95.         size = pinTextureSizeUnknown,
  96.     }
  97.     LMP:AddPinType(PINS_REALUNKNOWNPUBLICDUNGEON2, MapCallback_unknown, nil, pinLayout_RealUnknownPublicDungeon2, pinTooltipCreator)
  98.     local pinLayout_RealUnknown = {
  99.         level = pinTextureLevelUnknown,
  100.         texture = pinTextures.unknownrealpins[22],
  101.         size = pinTextureSizeUnknown,
  102.     }
  103.     LMP:AddPinType(PINS_REALUNKNOWN, MapCallback_unknown, nil, pinLayout_RealUnknown, pinTooltipCreator)
If I change "pinTooltipCreator" in each line to "nil" then nothing is written, so my guess is that it's all the calls to that one?
  Reply With Quote
11/13/14, 04:14 PM   #6
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Ah, you are right. All pin types has the same creator function, so the same function is called for each pin type. Not only when you register pins using the AddPinType, but every time when you change zone.

There are several ways how to fix the issue, for example:
- the same way as I have it done in SkyShards, call create function with some delay and make sure that you will call it just once. Simple function (I have a bit more complex function in SkyShards):
Lua Code:
  1. local updating = false
  2. local function QueueCreatePins()
  3.     if not updating then
  4.         updating = true
  5.         zo_callLater(CreateMapPins, 50) --do not forget to set updating to false at the end of CreateMapPins function
  6.     end
  7. end
- add some conditions to the CreateMapPins function, so pin will be created only once. This is inefficient, it will be slow because you will need to go through your data table for each pintype.
- make different function for each pintype. Again, this will be inefficient as you will need to go through your data table more times.
  Reply With Quote
11/13/14, 04:59 PM   #7
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Originally Posted by Garkin View Post
Ah, you are right. All pin types has the same creator function, so the same function is called for each pin type. Not only when you register pins using the AddPinType, but every time when you change zone.

There are several ways how to fix the issue, for example:
- the same way as I have it done in SkyShards, call create function with some delay and make sure that you will call it just once. Simple function (I have a bit more complex function in SkyShards):
Lua Code:
  1. local updating = false
  2. local function QueueCreatePins()
  3.     if not updating then
  4.         updating = true
  5.         zo_callLater(CreateMapPins, 50) --do not forget to set updating to false at the end of CreateMapPins function
  6.     end
  7. end
- add some conditions to the CreateMapPins function, so pin will be created only once. This is inefficient, it will be slow because you will need to go through your data table for each pintype.
- make different function for each pintype. Again, this will be inefficient as you will need to go through your data table more times.
That delay sounds like a solution, but how can I get that to work with this?:
Lua Code:
  1. local function MapCallback_unknown(pinManager)
  2.     CreateMapPins(PINS_UNKNOWN, false)
  3. end
  Reply With Quote
11/13/14, 05:23 PM   #8
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by SnowmanDK View Post
That delay sounds like a solution, but how can I get that to work with this?:
Lua Code:
  1. local function MapCallback_unknown(pinManager)
  2.     CreateMapPins(PINS_UNKNOWN, false)
  3. end
It should be something like the folowing code. Take a look to the SkyShards code for better reference.

Lua Code:
  1. local updating = false
  2.  
  3. local function CreateMapPins(pinType, known)
  4.     local zoneIndex = GetCurrentMapZoneIndex()
  5.     local data = MapDataStore[GetCurrentMapZoneIndex()]
  6.     for i = 1, GetNumPOIs(zoneIndex) do
  7.         local normalizedX, normalizedY, poiType, icon = GetPOIMapInfo(zoneIndex, i)
  8.         local unknown = (poiType == MAP_PIN_TYPE_INVALID)
  9.         local objectiveName = GetPOIInfo(zoneIndex, i)
  10.         local poiTypeId = 22
  11.         local poiTypeName
  12.         local pinTag
  13.         if data then
  14.             for _, pinLookup in ipairs(data) do
  15.                 if pinLookup[1] == objectiveName then
  16.                     poiTypeId = pinLookup[2]
  17.                     break
  18.                 end
  19.             end
  20.         end
  21.         poiTypeName = GetPoiTypeName(poiTypeId)
  22.         if unknown then
  23.             if not known then
  24.                 pinTag = {zo_strformat("|c0099CC<<t:1>>|r", objectiveName), zo_strformat("[<<t:1>>]", poiTypeName)}
  25.                 if localLanguage ~= "en" and savedVariables.filters[PINS_ADD_ENGLISH] == true then
  26.                     if englishPOINames[zoneIndex] and englishPOINames[zoneIndex][i] then
  27.                         table.insert(pinTag, 2, zo_strformat("|c006688<<t:1>>|r", englishPOINames[zoneIndex][i])) --insert english name as a second tooltip line
  28.                     end
  29.                 end
  30.                 local index = savedVariables.pinTextureUnknown.type
  31.                 if index == 7 then
  32.                     if poiTypeId == 1 then
  33.                         pinType = PINS_REALUNKNOWNWAYSHRINE
  34.                         local data = GuildTraderDataStore[GetCurrentMapZoneIndex()]
  35.                         if not data then return end
  36.                         for _, pinData in ipairs(data) do
  37.                             local ID = pinData[GuildTraderDataIndex.ID]
  38.                             if ID == 1 then
  39.                                 local WAYSHRINE = pinData[GuildTraderDataIndex.WAYSHRINE]
  40.                                 if WAYSHRINE == objectiveName then
  41.                                     table.insert(pinTag, 3, zo_strformat("|c666666<<t:1>>|r", GetString(POITYPE_GUILDTRADERS)))
  42.                                     pinType = PINS_REALUNKNOWNWAYSHRINETRADER
  43.                                 end
  44.                             end
  45.                         end
  46.                     elseif poiTypeId == 2 then
  47.                         pinType = PINS_REALUNKNOWNAOI
  48.                     elseif poiTypeId == 3 and zoneIndex ~= 353 then
  49.                         pinType = PINS_REALUNKNOWNPUBLICDUNGEON
  50.                     elseif poiTypeId == 3 and zoneIndex == 353 then
  51.                         pinType = PINS_REALUNKNOWNPUBLICDUNGEON2
  52.                     elseif poiTypeId == 4 then
  53.                         pinType = PINS_REALUNKNOWNMUNDUS
  54.                     elseif poiTypeId == 5 then
  55.                         pinType = PINS_REALUNKNOWNDOLMEN
  56.                     elseif poiTypeId == 6 then
  57.                         pinType = PINS_REALUNKNOWNGROUPBOSS
  58.                     elseif poiTypeId == 7 then
  59.                         pinType = PINS_REALUNKNOWNGROUPDUNGEON
  60.                     elseif poiTypeId == 8 then
  61.                         pinType = PINS_REALUNKNOWNQUESTHUB
  62.                     elseif poiTypeId == 9 then
  63.                         pinType = PINS_REALUNKNOWNCRAFTING
  64.                     elseif poiTypeId == 10 then
  65.                         pinType = PINS_REALUNKNOWNSOLODUNGEON
  66.                     elseif poiTypeId == 11 then
  67.                         pinType = PINS_REALUNKNOWNGROUPEVENT
  68.                     elseif poiTypeId == 12 then
  69.                         pinType = PINS_REALUNKNOWNGROUPDELVE
  70.                     elseif poiTypeId == 13 then
  71.                         pinType = PINS_REALUNKNOWNTRIAL
  72.                     elseif poiTypeId == 14 then
  73.                         pinType = PINS_REALUNKNOWNGUILDTRADER
  74.                     else
  75.                         pinType = PINS_REALUNKNOWN
  76.                     end
  77.                 end
  78.                 LMP:CreatePin(pinType, pinTag, normalizedX, normalizedY)
  79.             end
  80.         else
  81.             if known then
  82.                 if GetMapType() ~= 1 then
  83.                     pinTag = {zo_strformat("<<t:1>>", objectiveName), zo_strformat("[<<t:1>>]", poiTypeName)}
  84.                     if localLanguage ~= "en" and savedVariables.filters[PINS_ADD_ENGLISH] == true then
  85.                         if englishPOINames[zoneIndex] and englishPOINames[zoneIndex][i] then
  86.                             if poiTypeName == "Oratoire" or poiTypeName == "Wegschrein" then
  87.                                 pinTag = {zo_strformat("|c777755<<t:1>>|r", englishPOINames[zoneIndex][i]), zo_strformat("[<<t:1>>]", poiTypeName)}
  88.                             else
  89.                                 table.insert(pinTag, 2, zo_strformat("|c777755<<t:1>>|r", englishPOINames[zoneIndex][i]))
  90.                             end
  91.                         end
  92.                     end
  93.                     if poiTypeName ~= "Wayshrine" then
  94.                         LMP:CreatePin(pinType, pinTag, normalizedX, normalizedY)
  95.                     end
  96.                 end
  97.             end
  98.         end
  99.     end
  100.     updating = false
  101. end
  102.  
  103. local function QueueCreatePins(pinType, known)
  104.     if not updating then
  105.         updating = true
  106.         zo_callLater(function() CreateMapPins(pinType, known) end, 50)
  107.     end
  108. end
  109.  
  110. local function MapCallback_unknown(pinManager)
  111.     if not LMP:IsEnabled(PINS_UNKNOWN) or (GetMapType() > MAPTYPE_ZONE) then return end
  112.     QueueCreatePins(PINS_UNKNOWN, false)
  113. end

Last edited by Garkin : 11/13/14 at 05:28 PM.
  Reply With Quote
11/13/14, 06:27 PM   #9
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Originally Posted by Garkin View Post
It should be something like the folowing code. Take a look to the SkyShards code for better reference.

Lua Code:
  1. local updating = false
  2.  
  3. local function CreateMapPins(pinType, known)
  4.     local zoneIndex = GetCurrentMapZoneIndex()
  5.     local data = MapDataStore[GetCurrentMapZoneIndex()]
  6.     for i = 1, GetNumPOIs(zoneIndex) do
  7.         local normalizedX, normalizedY, poiType, icon = GetPOIMapInfo(zoneIndex, i)
  8.         local unknown = (poiType == MAP_PIN_TYPE_INVALID)
  9.         local objectiveName = GetPOIInfo(zoneIndex, i)
  10.         local poiTypeId = 22
  11.         local poiTypeName
  12.         local pinTag
  13.         if data then
  14.             for _, pinLookup in ipairs(data) do
  15.                 if pinLookup[1] == objectiveName then
  16.                     poiTypeId = pinLookup[2]
  17.                     break
  18.                 end
  19.             end
  20.         end
  21.         poiTypeName = GetPoiTypeName(poiTypeId)
  22.         if unknown then
  23.             if not known then
  24.                 pinTag = {zo_strformat("|c0099CC<<t:1>>|r", objectiveName), zo_strformat("[<<t:1>>]", poiTypeName)}
  25.                 if localLanguage ~= "en" and savedVariables.filters[PINS_ADD_ENGLISH] == true then
  26.                     if englishPOINames[zoneIndex] and englishPOINames[zoneIndex][i] then
  27.                         table.insert(pinTag, 2, zo_strformat("|c006688<<t:1>>|r", englishPOINames[zoneIndex][i])) --insert english name as a second tooltip line
  28.                     end
  29.                 end
  30.                 local index = savedVariables.pinTextureUnknown.type
  31.                 if index == 7 then
  32.                     if poiTypeId == 1 then
  33.                         pinType = PINS_REALUNKNOWNWAYSHRINE
  34.                         local data = GuildTraderDataStore[GetCurrentMapZoneIndex()]
  35.                         if not data then return end
  36.                         for _, pinData in ipairs(data) do
  37.                             local ID = pinData[GuildTraderDataIndex.ID]
  38.                             if ID == 1 then
  39.                                 local WAYSHRINE = pinData[GuildTraderDataIndex.WAYSHRINE]
  40.                                 if WAYSHRINE == objectiveName then
  41.                                     table.insert(pinTag, 3, zo_strformat("|c666666<<t:1>>|r", GetString(POITYPE_GUILDTRADERS)))
  42.                                     pinType = PINS_REALUNKNOWNWAYSHRINETRADER
  43.                                 end
  44.                             end
  45.                         end
  46.                     elseif poiTypeId == 2 then
  47.                         pinType = PINS_REALUNKNOWNAOI
  48.                     elseif poiTypeId == 3 and zoneIndex ~= 353 then
  49.                         pinType = PINS_REALUNKNOWNPUBLICDUNGEON
  50.                     elseif poiTypeId == 3 and zoneIndex == 353 then
  51.                         pinType = PINS_REALUNKNOWNPUBLICDUNGEON2
  52.                     elseif poiTypeId == 4 then
  53.                         pinType = PINS_REALUNKNOWNMUNDUS
  54.                     elseif poiTypeId == 5 then
  55.                         pinType = PINS_REALUNKNOWNDOLMEN
  56.                     elseif poiTypeId == 6 then
  57.                         pinType = PINS_REALUNKNOWNGROUPBOSS
  58.                     elseif poiTypeId == 7 then
  59.                         pinType = PINS_REALUNKNOWNGROUPDUNGEON
  60.                     elseif poiTypeId == 8 then
  61.                         pinType = PINS_REALUNKNOWNQUESTHUB
  62.                     elseif poiTypeId == 9 then
  63.                         pinType = PINS_REALUNKNOWNCRAFTING
  64.                     elseif poiTypeId == 10 then
  65.                         pinType = PINS_REALUNKNOWNSOLODUNGEON
  66.                     elseif poiTypeId == 11 then
  67.                         pinType = PINS_REALUNKNOWNGROUPEVENT
  68.                     elseif poiTypeId == 12 then
  69.                         pinType = PINS_REALUNKNOWNGROUPDELVE
  70.                     elseif poiTypeId == 13 then
  71.                         pinType = PINS_REALUNKNOWNTRIAL
  72.                     elseif poiTypeId == 14 then
  73.                         pinType = PINS_REALUNKNOWNGUILDTRADER
  74.                     else
  75.                         pinType = PINS_REALUNKNOWN
  76.                     end
  77.                 end
  78.                 LMP:CreatePin(pinType, pinTag, normalizedX, normalizedY)
  79.             end
  80.         else
  81.             if known then
  82.                 if GetMapType() ~= 1 then
  83.                     pinTag = {zo_strformat("<<t:1>>", objectiveName), zo_strformat("[<<t:1>>]", poiTypeName)}
  84.                     if localLanguage ~= "en" and savedVariables.filters[PINS_ADD_ENGLISH] == true then
  85.                         if englishPOINames[zoneIndex] and englishPOINames[zoneIndex][i] then
  86.                             if poiTypeName == "Oratoire" or poiTypeName == "Wegschrein" then
  87.                                 pinTag = {zo_strformat("|c777755<<t:1>>|r", englishPOINames[zoneIndex][i]), zo_strformat("[<<t:1>>]", poiTypeName)}
  88.                             else
  89.                                 table.insert(pinTag, 2, zo_strformat("|c777755<<t:1>>|r", englishPOINames[zoneIndex][i]))
  90.                             end
  91.                         end
  92.                     end
  93.                     if poiTypeName ~= "Wayshrine" then
  94.                         LMP:CreatePin(pinType, pinTag, normalizedX, normalizedY)
  95.                     end
  96.                 end
  97.             end
  98.         end
  99.     end
  100.     updating = false
  101. end
  102.  
  103. local function QueueCreatePins(pinType, known)
  104.     if not updating then
  105.         updating = true
  106.         zo_callLater(function() CreateMapPins(pinType, known) end, 50)
  107.     end
  108. end
  109.  
  110. local function MapCallback_unknown(pinManager)
  111.     if not LMP:IsEnabled(PINS_UNKNOWN) or (GetMapType() > MAPTYPE_ZONE) then return end
  112.     QueueCreatePins(PINS_UNKNOWN, false)
  113. end
That is very close to what I tried. Sadly both mine and your code gives me these errors:

Line 2406:
Lua Code:
  1. QueueCreatePins(PINS_UNKNOWN, false)
Line 3488:
Lua Code:
  1. LMP:AddPinType(PINS_UNKNOWN, MapCallback_unknown, nil, pinLayout_unknown, pinTooltipCreator)
  Reply With Quote
11/13/14, 07:26 PM   #10
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Not sure this is the final solution, but it seems to work.
I did this directly, bypassing a loop through "QueueCreatePins".
Lua Code:
  1. local function MapCallback_unknown(pinManager)
  2.     if not LMP:IsEnabled(PINS_UNKNOWN) or (GetMapType() > MAPTYPE_ZONE) then return end
  3.     if not updating then
  4.         updating = true
  5.         zo_callLater(function() CreateMapPins(PINS_UNKNOWN, false) end, 50)
  6.     end
  7. end
  Reply With Quote
11/13/14, 07:58 PM   #11
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
After adding a function to toggle the RealPins on/off, and adding a call to that depending on switches in settings then it seems to work perfectly.

Once again you saved me Master Garkin

Only one issue left, but that's minor thing. It's even present in the current release.
Maybe you have an idea about what is going on with it.
When RealPins are selected then only Quest Hubs are shown in Coldharbour and The Rift.
It ONLY goes wrong in those 2 zones and ONLY when using "Semi-Real" pins.
I must admit I am beginning to suspect a problem in the API, as I can't find the reason.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Problem with Destinations


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off