04/10/14, 11:24 AM | #1 |
Problem Creating Map Pins ... Still
Still trying to fathom how the map pins appear on the map but so far I haven't figured it out. Perhaps someone with access to the extra information can point out where I am going wrong. I've been looking at Shinni's code as a guide and have slowly rewritten what I thought was how it should be done but as the screenshot shows no pin on the map. So I must be missing something somewhere.
Here is the code I have running at the moment. I have deliberately used the PlayerActivatedEvent instead of AddonLoaded so that I can debug my way through it. I know you probably can't give us too much information on this but a nudge into what is missing to make it work would be great. Lua Code:
|
|
04/10/14, 12:01 PM | #2 |
|
Lua Code:
pinType should be a unique name for your pin type. eg "Xrystal_Wood" if you want this pin type to represent wood harvest nodes for your gatherer. drawCallback is a function which receives a pin manager as argument. this function is called wenever the map is drawn. it's supposed to create your map pins eg: Lua Code:
note that zenimax's scripts internally use integers for pinTypes. the internal representation of the pin type "Xrystal_Wood" is saved in _G["Xrystal_Wood"]. the second argument of CreatePin is the pintag. you can use this to pass additional informations to later layout/tooltip functions resizeCallback is called whenever the map size changes, eg when the player zooms in. I always use nil as normal pins don't need to resize. this function gets 2 arguments: the new width and height. pinLayout is a table which represents the layout of all pins of this pin type it needs a key called texture for the pin texture, a key called level which determines which pin is drawn above the other. it can also have an optinal key called size. example: Lua Code:
pinTooltipCreator is another table which handles the tooltip obviously. example: Lua Code:
creator is a function which receives the pin and adds text to the tooltip. remember the pinTag (2nd argument of pinManager:CreatePin)? here you can use the additional data via pin.m_PinTag to enable a pin call Lua Code:
if you want to refresh the pins (because you changed layout information or something like that) call Lua Code:
Lua Code:
now back to your code: Lua Code:
i'd expect a buffer overflow here. drawCallback is called when the map is refreshed but your drawCallback forces the map to refresh again. the only reason your game didn't crash is because you didn't use _G[pinType] in the XMPins:RefreshCustomPins argument Last edited by Shinni : 04/10/14 at 12:06 PM. |
04/10/14, 12:14 PM | #3 |
Thanks Shinni,
I deliberately removed the _G[] around the pinTypes on the 2 functions that used it to see if it triggered an error but it didn't which I was quite surprised with. I will make the appropriate changes and see the result. Admittedly at present the pinType isn't exactly unique, but it shouldn't be affecting anything else I have loaded seeing as no other pins with the basic tradeskill names seem to exist. Obviously I would prefix it to make it unique. The pinManager part was confusing me but I will try to re-introduce it into my code and see if it improves things. Thanks for letting me know what is in the resizeCallback function. At present all my callbacks do is refresh the pins regardless of what happened. The reason being is that at present I am throwing the data straight into the pin table as a quick test on how this all works. Obviously in the real scenario I would have the drawCallback re-read the saved variable data and place the appropriate information into the pin table for use by the pin manager. I think I went over zealous with what looked like layout data after looking at your code comments so I set up some default values to use. Maybe not a good idea. Will revert back to level and texture and see how that works. Other than that I think I am square with the code now and if anything the revisiting of the code and rewriting I have done has helped me see what is what. Your help is much appreciated. I will have to make these changes later on and will report the results. Crossing fingers it will resolve my problems and I can move onto the next TODO on my list of things for my gatherer addon. |
|
04/10/14, 07:54 PM | #4 |
Hmm,
Still not working for me .. 1. Made sure ZO_WorldMap functions used _G[pinType] 2. Made sure pinType was prefixed with something to make it unique 3. Draw Callback function now uses pinManager parameter and cycles through the pinData table and calls pinManager:CreatePin with the data it holds, and removes the RefreshCustomPins function so it doesn't get into that loop ( yes it has happened before, had to crash out a few times ). 4. Set Resize Callback function to nil for the time being 5. Pin Layout table now just has texture, level and size values 6. Added tooltip value to tag/key table to use in the tooltip part of the AddCustomPin function. Obviously something else is missing in my code somewhere or in the wrong place. Don't think I missed anything, and did find a few bits of code with the wrong name that clearly isn't being used at present and didn't pick up on it. Here's the updated code with the above changes, minus the code that has been commented out. From your explanation I thought these changes would resolve it but there must be something else. I have tried both MapName and GetUnitZone functions as they sometimes return different values, just in case that was the reason. My understanding of the functionality is as follows: 1. Subclass an appropriate object ( I have tried both ZO_WorldMapPins and ZO_Object ) 2. New the subclassed variable into the usable variable 3. Initialise the pin types including a callback function,texture,tooltip etc and a call to the customised AddCustomPin function to add your data via ZO_WorldMap_AddCustomPin 4. Callback function to cycle through the pin data and create the individual pins at the stored location using the pin manager passed to the function whenever the map is redrawn 5. While still in the initialisation stage initialise the equivalent filters use your customised SetCustomPinEnabled and RefreshCustomPins functions to enable and refresh your pins using the ZO_WorldMap_RefreshCustomPinsOfType(_G[pinType]) and ZO_WorldMap_SetCustomPinEnabled(_G[pinType]) functions. 6. Not got as far as seeing how the RemovePins function works to know where that fits in. Did I miss anything out ? I hate it when something so apparently simple causes me no end of problems. Especially when I took this week off in the hopes of getting this fixed and catching up with the levelling by actually playing. Lua Code:
|
|
04/11/14, 06:32 AM | #5 |
|
only read the code, didn't test it. i noticed the following:
line 262 pinManager:CreatePin(_G[pinType], v.key, v.zone, v.x, v.y, v.radius) should be pinManager:CreatePin(_G[pinType], v.key, v.x, v.y, v.radius) line 271 local pinTooltipCreator = { creator = function(pin) InformationTooltip:AddLine(pin.key.tooltip) end, tooltip = InformationTooltip } should be local pinTooltipCreator = { creator = function(pin) InformationTooltip:AddLine(pin.m_PinTag.tooltip) end, tooltip = InformationTooltip } |
04/11/14, 06:41 AM | #6 |
Ah, those values are fixed to a specific variable.
I'm guessing then that the pinManager automatically places the co-ords in the correct zone ? Okay thanks, I'll give those 2 changes a try ..... *crosses fingers for when server comes back up* Last edited by Xrystal : 04/11/14 at 06:44 AM. |
|
04/11/14, 07:27 AM | #7 | |
|
though you have done that already: Lua Code:
edit: i think you have to remove SetMapToPlayerLocation(). if the player changes the currently displayed map (eg right click) the drawCallback is called and immediatly sets the map back to the player's position. |
|
04/11/14, 07:29 AM | #8 |
Good spot, still crossing fingers.
edit: Removed SetMapToPlayerLocation() call in drawCallback Revised CreatePin and TooltipCreator as per your comments *sigh* Still no pins. Are you sure I didn't miss anything vital out ? edit2: Moved the Filter creation into a separate function and called it before AddCustomPin just in case. I also changed it to WORLD_MAP_FILTERS.pvePanel:AddPinFilterCheckBox(_G[pinType], function() self:RefreshCustomPins(pinType) end) so that it would use my pin type rather than the '5' resource reference, just in case that was causing the problem. But nada. Still no pins being displayed. edit3: Had to remove above change as it reported an error saying a table didn't exist when you click on the buttons. So now the question arises as to whether it is the filters that are messing things up if changing to my pinType instead of 5. New filter code as follows, I am assuming the callback function is called when refreshing the filter option so I refreshed the pins there.: Lua Code:
Last edited by Xrystal : 04/11/14 at 08:54 AM. |
|
04/12/14, 02:46 AM | #9 |
|
I dont know how the filter worked anymore. Have you tried commenting that out? I cant find anything wrong so i guess its the filters.
Otherwise could you upload the complete addon? Its easier to debug code if i can test it. |
04/12/14, 07:02 AM | #10 |
Thanks, will tidy up the code and turn off the filter side of things and see if that makes a difference and will sort out something to post up the zip here on this thread rather than as a proper addon. It's only a test addon at the moment that will ultimately go into the gatherer addon once it's up and running.
I'm glad that you can't see anything wrong functionally as it means I at least had the idea right, just that somewhere something is going wrong, probably something silly that doesn't cause an error like my infamous = instead of == rofl. But that was the first thing I checked. edit: Okay, tidied up code, fixed a couple of visual glitches .. here's the code in its entirety. Everything seems to work except the drawing of the pin itself. Probably something so simple we'll kick ourselves. Me especially. Last edited by Xrystal : 04/12/14 at 10:03 AM. |
|
04/13/14, 10:08 AM | #11 |
|
you called
Lua Code:
Lua Code:
this should be Lua Code:
which then results in an attempt to index nil value error in Lua Code:
you probably want to iterate over SVData. |
04/13/14, 11:08 AM | #12 |
Hmm, quite possibly, it's not erroring out. But will investigate those code areas.
|
|
04/13/14, 11:51 AM | #13 |
Thanks a lot Shinni, that worked.
The problem was that I wasn't validating whether any pin data had been added to the custom pin object before trying to traverse it. Plus the enable function not having its call also use the enable flag. I knew it must have been something silly once you couldn't see why it wasn't working. |
|
ESOUI » Developer Discussions » Lua/XML Help » Problem Creating Map Pins ... Still |
«
Previous Thread
|
Next Thread
»
|
Thread Tools | |
Display Modes | |
|
|