Thread Tools Display Modes
04/25/14, 10:52 AM   #1
skv1991
Join Date: Apr 2014
Posts: 5
Red face Map Pins

Hello everybody, I really want to make my first little AddOn, wich will just show Trunks and Nightshades on Map, I just need a mod.lua(logic) and modData.lua (contain array with coordinates and icon), mod.txt(manifest), and icons folder.

Can you help me?
I read Tutorial on Wiki, but I can't understand how Pins(CustomCompassPins) library works.

I never before work with Lua, but I work with many script languages =)

AddOn name: SKVTrunkMap

SKVTrunkMap.txt
Code:
## Title: SKV1991 Addon
## Version: 0.0.1
## Author: |ca200ffskv1991|r
## APIVersion: 100003
## SavedVariables: SKVTM_SavedVariables
## OptionalDependsOn: CustomCompassPins

Libs/CustomCompassPins/CustomCompassPins.lua

SKVTrunkMap.lua
SKVTrunkMap.xml
SKVTrunkMap.lua
Code:
-------------------------------------------------------------------------------
-- SKVTrunkMap v0.0.1 
-------------------------------------------------------------------------------

if SKVTM == nil then SKVTM = {} end

	
function OnLoad()
	CHAT_SYSTEM:AddMessage("AddOn started")
end

-- slash commands
	SLASH_COMMANDS["/skvtm"] = OnLoad

EVENT_MANAGER:RegisterForEvent("SKVTrunkMap_OnLoad", EVENT_ADD_ON_LOADED, OnLoad)
Custom Compass Pins

Icons
Skvtrunk.dds

Can you explain, how to work with CustomCompassPins and how to add my icons to map?
I don't want to make it like SkyShards map, only icon(s) at specific coordinates.

Help newbie become modder please!
  Reply With Quote
04/25/14, 03:27 PM   #2
Shinni
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 167
that library creates compass pins, not mappins.
this post might help you:
http://www.esoui.com/forums/showpost...10&postcount=2
  Reply With Quote
04/25/14, 04:08 PM   #3
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by skv1991 View Post
Warning: Spoiler
1) EVENT_ON_ADDON_LOADED is fired for each addon, so you have to check if loaded addon is yours -
Lua Code:
  1. function OnLoad(eventCode, addonName)
  2.     if addonName ~= myaddon then return end
  3.  
  4.     CHAT_SYSTEM:AddMessage("AddOn started")
  5. end
"myaddon" is name of your addon, and it is usualy case-sensitive file name without .lua

2) CustomCompassPins library does not add map pins to the WorldMap, it shows markers on compass.
If you want to add pins to the WorldMap, you should use:
Lua Code:
  1. ZO_WorldMap_AddCustomPin(pinType, pinTypeAddCallback, pinTypeOnResizeCallback, pinLayoutData, pinTooltipCreator)
  2. ZO_WorldMap_SetCustomPinEnabled(_G[pinType], true)
  3. ZO_WorldMap_RefreshCustomPinsOfType(_G[pinType])

where:
pinType = unique string that defines category of your pins

pinTypeAddCallback = function(pinManager) that is called every time when map is changed and should create pins for given area. Example function (CreateMapPins):
Lua Code:
  1. local pinData = {
  2.    ["Auridon"] = {
  3.       { 0.500, 0.500, "Pin1" },
  4.       { 0.250, 0.250, "Pin2" },
  5.    },
  6.    ["Stonefalls"] = {
  7.       { 0.750, 0.750, "Pin3" },
  8.       { 0.320, 0.845, "Pin4" },
  9.    },
  10. }
  11.  
  12. local function CreateMapPins(pinManager)
  13.    local mapname = GetMapName()
  14.  
  15.    if pinData[mapname] == nil then return end
  16.  
  17.    local mydata = pinData[mapname]
  18.  
  19.    for _, pinTag in ipairs(mydata) do
  20.       --pinType is the same string as used in "ZO_WorldMap_AddCustomPin(...)" function
  21.       --pinTag can be anything unique, but it is usefull if it is table that contains information about map pin
  22.       pinManager:CreatePin(_G[pinType], pinTag, pinTag[1], pinTag[2])
  23.    end
  24. end

pinTypeOnResizeCallback = function(pinManager, mapWidth, mapHeight), called every time when map is resized (zoom). Usualy not defined (nil).

pinLayoutData = table that contains:

Lua Code:
  1. pinLayoutData  = {
  2.    level = 40,
  3.    textue = "MyAddon/Icons/pin.dds",
  4.    size = 32,
  5. }
  6.  
  7. --pinLayoutData = {
  8. --   level =  ??    --required and must be >2. Pins with higher level will
  9. --                       be drawn on the top of pins with lower level.
  10. --                       Example:
  11. --                          points of interests = 50,
  12. --                          AvA objectives = 50-100
  13. --                          quests = 110
  14. --                          group members = 130
  15. --                          wayshrine = 140
  16. --                          player = 160
  17. --   texture = ??  --requred, can be string or function. Function can return just a background texture or
  18. --                        background, pulse and glow texture.
  19. --                     --Examples:
  20. --                       "YourAddon/Icons/Icon.dds"
  21. --                       or
  22. --                       function = GetTexture(pin)
  23. --                          local texture1 = "YourAddon/Icons/Icon1.dds"
  24. --                          local texture2 = "YourAddon/Icons/Icon2.dds"
  25. --                          if pin.m_PinTag[3] == "Pin1" then
  26. --                             return texture1
  27. --                          else
  28. --                             return texture2
  29. --                          end
  30. --                       end
  31. --   size = ??,     --texture will be resized to square size*size. If not
  32. --                       specified, default value is 20.
  33. --                       Examples:
  34. --                          point of interest = 40
  35. --                          quest pins = 32
  36. --                          player = 16
  37. --   insetX = ??,  --size of transparent texture border, used to determine
  38. --   insetY = ??,     if mouse click hits this pin. No need to specify if
  39. --                    you do not plan to handle mouse clicks.
  40. --   minSize = ??, --if not specified, default value is 18.
  41. --   minAreaSize,
  42. --   showsPinAndArea,  --true/false
  43. --   isAnimated,       --true/false
  44. --}

pinTooltipCreator is a table that contains function that creates tooltip and type of tooltip you want to use.
Lua Code:
  1. local pinTooltipCreator = {
  2.     creator = function(pin)
  3.         InformationTooltip:AddLine("This is my tooltip")
  4.     end,
  5.     tooltip = InformationTooltip,
  6. }
For better example code check code of Shinni's HarvestMap or my LoreBooks and SkyShards.

Last edited by Garkin : 05/16/14 at 08:03 AM. Reason: Removed icon:SetDesaturation() as it was not good example - you have to hook function in order to reset it back.
  Reply With Quote
04/26/14, 03:43 AM   #4
skv1991
Join Date: Apr 2014
Posts: 5
Guys, thank you so much for information! I will use it!

But why I can't see a text in chat, while AddOn is loaded?

txt
Code:
## Title: |cFFFFB0SKVTrunkMap|r 0.0.1 - By |ca200ffSKV1991|r
## Version: 0.0.1
## Author: skv1991
## APIVersion: 100003
## SavedVariables: SKVTM_SavedVariables

Libs/CustomCompassPins/CustomCompassPins.lua

SKVTrunkMap.lua
lua
Lua Code:
  1. -------------------------------------------------------------------------------
  2. -- SKVTrunkMap v0.0.1
  3. -------------------------------------------------------------------------------
  4. function OnLoad(eventCode, addonName)
  5.     if addonName ~= "SKVTrunkMap" then return end
  6.  
  7.     CHAT_SYSTEM:AddMessage("AddOn started")
  8. end
  9.  
  10.  
  11. EVENT_MANAGER:RegisterForEvent("SKVTrunkMap", EVENT_ADD_ON_LOADED, OnLoad)

In AddOn's menu my mod is active, where I do something wrong? Haha, thats easy but I can't get that
But if I put message in local function and call it using SLASH_COMMANDS, iI recieve message properly, whats wrong with Events?


Here another example

Lua Code:
  1. -------------------------------------------------------------------------------
  2. -- SKVTrunkMap v0.0.1
  3. -------------------------------------------------------------------------------
  4. if SKVTM == nil then SKVTM = {} end
  5.  
  6. local pinType  = "SKVTMPin";
  7.  
  8. function OnLoad(eventCode, addonName)
  9.     if addonName ~= "SKVTrunkMap" then return end
  10.  
  11.     CHAT_SYSTEM:AddMessage("AddOn started")
  12. end
  13.  
  14. local function MBox(...)
  15.     CHAT_SYSTEM:AddMessage(...)
  16. end
  17.  
  18. local pinData = {
  19.        ["Stonefalls"] = {
  20.           { 0.750, 0.750, "Pin3" },
  21.           { 0.320, 0.845, "Pin4" },
  22.        },
  23.        ["Eastmarch"] = {
  24.           { 0.285, 0.381, "Pin3" },
  25.        },
  26.        ["Windhelm"] = {
  27.           { 0.271, 0.309, "Lol" },
  28.        },
  29. }
  30.  
  31. local function CreateMapPins(pinManager)
  32.    local mapname = GetMapName()
  33.  
  34.    if pinData[mapname] == nil then return end
  35.  
  36.    local mydata = pinData[mapname]
  37.  
  38.    for _, pinTag in ipairs(mydata) do
  39.       --pinType is the same string as used in "ZO_WorldMap_AddCustomPin(...)" function
  40.       --pinTag can be anything unique, but it is usefull if it is table that contains information about map pin
  41.       pinManager:CreatePin(_G[pinType], pinTag, pinTag[1], pinTag[2])
  42.    end
  43. end
  44.  
  45. local pinLayoutData  = {
  46.        level = 40,
  47.        textue = "SKVTrunkMap/Icons/Skvtrunk.dds",
  48.        size = 32, -- Size of icon
  49. }
  50.  
  51. local pinTooltipCreator = {
  52.     creator = function(pin)
  53.         InformationTooltip:AddLine("This is my tooltip")
  54.     end,
  55.     tooltip = InformationTooltip,
  56. }
  57.  
  58. local function myPosition()
  59.     local x, y = GetMapPlayerPosition("player")
  60.     local map = GetMapName()
  61.     local locX = string.format("%03d", zo_round(x*1000))
  62.     local locY = string.format("%03d", zo_round(y*1000))
  63.     MBox(map .. ": " .. locX .. "," .. locY)
  64. end
  65.  
  66. local function DoStuff()
  67.  
  68.     --AddMapPin("SKVTM_Pins", MapCallback, nil, pinLayoutData, pinTooltipCreator)
  69.    
  70.     ZO_WorldMap_AddCustomPin(pinType, pinTypeAddCallback, nil, pinLayoutData, pinTooltipCreator)
  71.     ZO_WorldMap_SetCustomPinEnabled(_G[pinType], true)
  72.     ZO_WorldMap_RefreshCustomPinsOfType(_G[pinType])
  73.    
  74.     if GetMapName() == "Windhelm" then MBox("Added") end
  75.  
  76. end
  77.  
  78. -- slash commands
  79.     SLASH_COMMANDS["/skvmp"] = myPosition
  80.     SLASH_COMMANDS["/skvdo"] = DoStuff
  81.  
  82. EVENT_MANAGER:RegisterForEvent("SKVTrunkMap", EVENT_ADD_ON_LOADED, OnLoad)

When I type /skvdo, I recieve these errors:

Last edited by skv1991 : 04/26/14 at 04:16 AM.
  Reply With Quote
04/26/14, 04:10 AM   #5
Shinni
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 167
But why I can't see a text in chat, while AddOn is loaded?
the chat isn't initialized yet. the earliest event with a loaded chat is EVENT_PLAYER_ACTIVATED, if i'm not mistaken.
This event is fired after every loading screen, so you may want to call
EVENT_MANAGER:UnregisterForEvent("addonname", EVENT_PLAYER_ACTIVATED)
in that callback function.


Code:
ZO_WorldMap_AddCustomPin(pinType, pinTypeAddCallback, nil, pinLayoutData, pinTooltipCreator)
replace pinTypeAddCallback with CreateMapPins.

Last edited by Shinni : 04/26/14 at 04:22 AM.
  Reply With Quote
04/26/14, 04:28 AM   #6
skv1991
Join Date: Apr 2014
Posts: 5
Originally Posted by Shinni View Post
replace pinTypeAddCallback with CreateMapPins.
Yeah, thats working! But map icon looks like white square

mistake in
lua Code:
  1. local pinLayoutData  = {
  2.        level = 40,
  3.        textue = "SKVTrunkMap/Icons/Skvtrunk.dds",
  4.        size = 32, -- Size of icon
  5. }
textue I replace with texture and all works!



Now I need to add more funcionality and, maybe, compass data =) BIG thanks guys, I will write code here, when I'm done =)

Last edited by skv1991 : 04/26/14 at 05:19 AM.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Map Pins


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