Originally Posted by Wandamey
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:
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:
-- approx. line 3177
local tooltipText = {
-- add this table
lures = {},
}
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:
elseif TYPE == 43 then
--[[
fishingBaitLeft = tostring(LakeBaitLeft).."/"..tostring(LakeSBaitLeft)
if GeneralBait >= 1 then
fishingBaitLeft = fishingBaitLeft.."/"..tostring(GeneralBait)
table.insert(tooltipText.lures, 0)
end
textLine = textLine + 1
table.insert(tooltipText, textLine, ZO_ColorDef:New(unpack(DestinationsSV.pins.pinTextureFish.textcolorBait)):Colorize(zo_strformat("<<1>>", "{"..fishingBaitLeft.."}")))
--]]
-- Decide which lureIndices should be used & add them to the table
-- 5 = just an example of some lure Index usable in this water
table.insert(tooltipText.lures, 5)
-- add as many lure indices as needed, insert them in the order
-- you want them displayed in
Do the lure counts in the tooltip creator
Lua Code:
local pinTooltipCreator = {
creator = function(pin)
local pinType, pinTag = pin:GetPinTypeAndTag()
-- do it here
-- You may need some check to make sure its a fishing map pin
-- if pinType == xxxxx then
local lures = pinTag.lures
local tooltipLureCountText
for _, lureIndex in pairs(lures) do
-- updates bait count
local name, icon, stack, sellPrice, quality = GetFishingLureInfo(lureIndex)
-- If you need something more complex than just the
-- lure counts in the backpack call a custom function instead
-- to do that work
--local stack = UpdateLureCount(lureIndex)
-- if you need to save counts for use in other places besides the tooltip save it here
-- someTable.whatever[lureIndex] = stack
-- build the tooltip text line for lure counts as you go
if tooltipLureCountText then
tooltipLureCountText = zo_strformat("<<1>>/<<2>>", tooltipLureCountText, stack)
else
tooltipLureCountText = stack
end
end
-- add your { }
tooltipLureCountText = zo_strformat("{<<1>>}", tooltipLureCountText)
-- Update the new string in your tag:
pinTag[4] = tooltipLureCountText
--end
for _, lineData in ipairs(pinTag) do
SetTooltipText(InformationTooltip, lineData)
end
end,
tooltip = 1,
}