View Single Post
12/26/15, 09:37 PM   #33
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by Wandamey View Post
re edit : you are using local lureIndex = GetFishingLure() at first? It probably just return the index of the current lure on the rod? not sure. but anyway you are using it as the indice 2 lines later. Doesn't seem needed at all.
Oops, your right that's pointless. It was supposed to be
Lua Code:
  1. local lureIndex = lureIndex or GetFishingLure()
I wrote the function one way & then changed it and missed that and yes it returns the index of the lure on the rod which was part of some code I sent him to check the counts after fishing so only the index of the lure on the rod was needed for that code.

As for the map change talk...it seems like you only need this info for the map pin tooltip so why not just do it in the creator?
Map pin tooltips are re-created everytime they are shown, so your bait count update code would only have to run when a tooltip is shown, which sounds like the only time you need the updated count.
Also that way you would not have to re-check the counts for all of the types of baits. Since you would know which map pin the tooltip is for, you know which baits you are wanting to display and you only have to update those bait counts.


Add a lures table to your pin tag to hold the usable lureIndices:
Lua Code:
  1. -- approx. line 3177
  2. local tooltipText = {
  3.    -- add this table
  4.    lures = {},
  5. }

Then instead of creating the string {3/1/71} for counts in FishpinTypeCallback, just determine which lureIndex is usable in that water and put those lure indices in the lures table in the tag.
Lua Code:
  1. elseif TYPE == 43 then
  2. --[[
  3.     fishingBaitLeft = tostring(LakeBaitLeft).."/"..tostring(LakeSBaitLeft)
  4.     if GeneralBait >= 1 then
  5.         fishingBaitLeft = fishingBaitLeft.."/"..tostring(GeneralBait)
  6.     table.insert(tooltipText.lures, 0)
  7.     end
  8.     textLine = textLine + 1
  9.     table.insert(tooltipText, textLine, ZO_ColorDef:New(unpack(DestinationsSV.pins.pinTextureFish.textcolorBait)):Colorize(zo_strformat("<<1>>", "{"..fishingBaitLeft.."}")))
  10. --]]
  11.     -- Decide which lureIndices should be used & add them to the table
  12.         -- 5 = just an example of some lure Index usable in this water
  13.     table.insert(tooltipText.lures, 5)
  14.     -- add as many lure indices as needed, insert them in the order
  15.     -- you want them displayed in


Do the lure counts in the tooltip creator
Lua Code:
  1. local pinTooltipCreator = {
  2.     creator = function(pin)
  3.         local pinType, pinTag = pin:GetPinTypeAndTag()
  4.        
  5.         -- do it here
  6.         -- You may need some check to make sure its a fishing map pin
  7.         -- if pinType == xxxxx then
  8.             local lures = pinTag.lures
  9.             local tooltipLureCountText
  10.            
  11.             for _, lureIndex in pairs(lures) do
  12.                 -- updates bait count
  13.                 local name, icon, stack, sellPrice, quality  = GetFishingLureInfo(lureIndex)   
  14.            
  15.                 -- If you need something more complex than just the
  16.                 -- lure counts in the backpack call a custom function instead
  17.                 -- to do that work
  18.                 --local stack = UpdateLureCount(lureIndex)
  19.  
  20.                 -- if you need to save counts for use in other places besides the tooltip save it here
  21.                 -- someTable.whatever[lureIndex] = stack
  22.  
  23.                 -- build the tooltip text line for lure counts as you go
  24.                 if tooltipLureCountText then
  25.                     tooltipLureCountText = zo_strformat("<<1>>/<<2>>", tooltipLureCountText, stack)
  26.                 else
  27.                     tooltipLureCountText = stack
  28.                 end
  29.             end
  30.             -- add your { }
  31.             tooltipLureCountText = zo_strformat("{<<1>>}", tooltipLureCountText)
  32.            
  33.             -- Update the new string in your tag:
  34.             pinTag[4] = tooltipLureCountText
  35.         --end
  36.        
  37.        
  38.         for _, lineData in ipairs(pinTag) do
  39.             SetTooltipText(InformationTooltip, lineData)
  40.         end
  41.     end,
  42.     tooltip = 1,
  43. }

Last edited by circonian : 12/26/15 at 11:12 PM.
  Reply With Quote