Thread Tools Display Modes
10/22/14, 09:14 PM   #1
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Destinations custom pin problem

I guess I have been staring at this problem for too long as I can't see the problem. Hope some here can help

I am trying to add a custom pin for unknown wayshrines with a nearby guild trader using this code:
Lua Code:
  1. -- insert custom pin for wayshrines
  2.                         local data = GuildTraderDataStore[GetCurrentMapZoneIndex()]
  3.                         if not data then return end
  4.                         for _, pinData in ipairs(data) do
  5.                             local WAYSHRINE = pinData[GuildTraderDataIndex.WAYSHRINE]
  6.                             if WAYSHRINE == objectiveName then
  7.                                 table.insert(pinTag, 3, zo_strformat("|c666666<<t:1>>|r", GetString(POITYPE_GUILDTRADERS)))
  8.                                 LMP:SetLayoutKey(pinType, "texture", pinTextures.unknownrealpins[15])
  9.                                 LMP:CreatePin(pinType, pinTag, normalizedX, normalizedY)
  10.                                 break
  11.                             else
  12.                                 LMP:SetLayoutKey(pinType, "texture", pinTextures.unknownrealpins[1])
  13.                                 LMP:CreatePin(pinType, pinTag, normalizedX, normalizedY)
  14.                                 break
  15.                             end
  16.                         end
using these data (example):
Lua Code:
  1. ----Deshaan
  2.     [11] = {
  3.         {"Muth Gnaar Hills Wayshrine"},
  4.         {"Tal'Deic Grounds Wayshrine"},
  5.     },
For some reason it only returns the FIRST wayshrine on my list. It's the same on all maps. Only the first is returned, as if "GuildTraderDataIndex.WAYSHRINE" only reads the first, BUT it reads it as many times as there are wayshrines on the list, so the Deshaan example are returned twice, hence the "Break" command which makes it return only once.
What am I doing wrong?

Last edited by SnowmanDK : 10/22/14 at 09:16 PM.
  Reply With Quote
10/22/14, 10:32 PM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
It seems that this will work only for the first item in the data table. No matter if condition is true or false, in both cases is called "break" to end the for loop.

If I understand correctly, you want special icons for undiscovered wayshrines that are somewhere on your list.

1) If you are using different pin type for selected wayshrines, you will need to modify CreateMapPins function - check if POI is wayshrine (if poiTypeId == 1 then) and then check if wayshrine is on your list and then select correct pin type the new pin.

2) If you are using the same pin type but you want different texture, you will need change pin layout - instead of texture path use function(pin) which returns texture path. To this function add check if that wayshrine is on your list and then return icon which you want to use.

As I can see in Destinations, you are changing pin texture using the LMP:SetLayoutKey(..). It works well if you want to change texture for all pins. But it can cause unexpected results if you are changing textures just for selected pins - for example pins can have wrong textures on minimap.
I recommend using function in the pin layout or two different pin types. How function works is described in comments in LinMapPins-1.0.lua, or you can take a look to the LoreBooks code.

Last edited by Garkin : 10/23/14 at 08:24 AM. Reason: fixed typo
  Reply With Quote
10/23/14, 06:12 PM   #3
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Originally Posted by Garkin View Post
It seems that this will work only for the first item in the data table. No matter if condition is true or false, in both cases is called "break" to end the for loop.

If I understand correctly, you want special icons for undiscovered wayshrines that are somewhere on your list.

1) If you are using different pin type for selected wayshrines, you will need to modify CreateMapPins function - check if POI is wayshrine (if poiTypeId == 1 then) and then check if wayshrine is on your list and then select correct pin type the new pin.

2) If you are using the same pin type but you want different texture, you will need change pin layout - instead of texture path use function(pin) which returns texture path. To this function add check if that wayshrine is on your list and then return icon which you want to use.

As I can see in Destinations, you are changing pin texture using the LMP:SetLayoutKey(..). It works well if you want to change texture for all pins. But it can cause unexpected results if you are changing textures just for selected pins - for example pins can have wrong textures on minimap.
I recommend using function in the pin layout or two different pin types. How function works is described in comments in LinMapPins-1.0.lua, or you can take a look to the LoreBooks code.
It was actually you who showed me to use LMP:SetLayoutKey(..)
I think I have found a solution that works, although it still uses the SetLayoutKey(..) (at least for me). I am gonna do a bit more testing then I'll release it.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Destinations custom pin problem


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