Thread Tools Display Modes
12/22/15, 03:22 PM   #1
Wandamey
Guest
Posts: n/a
Originally Posted by votan View Post

Code:
...
For counting the baits, you could try circonian's idea.

/edit: Ok, I'm even more slow
that's nice, I managed to place my post right when I could pretend it was useful

edit cross post with SMDK if you wait 5 mn, i'm sure votan will help with a tested version of bait listing by id and something like this :

local fakeitemLink = zo_strformat(|H0blablabla<<1>>blablabla|h|h, baitId) <---build an ItemLink with no name
zo_strformat(<<1>>,GetItemLinkName(fakeitemLink)) <-- get localized name - format or not depending on the value returned by GetFishingLureInfo or format both the same to compare
(all you need to do this is in fisherman, file Baits.lua btw : all ids, the localized name function too)


but i think you are able to simply make a table lure[itemId] = lureindex, i'm pretty sure these indexes are stable because of the selection wheel.

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.

Last edited by Wandamey : 12/22/15 at 03:53 PM.
  Reply With Quote
12/22/15, 04:13 PM   #2
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Originally Posted by Wandamey View Post
that's nice, I managed to place my post right when I could pretend it was useful

edit cross post with SMDK if you wait 5 mn, i'm sure votan will help with a tested version of bait listing by id and something like this :

local fakeitemLink = zo_strformat(|H0blablabla<<1>>blablabla|h|h, baitId) <---build an ItemLink with no name
zo_strformat(<<1>>,GetItemLinkName(fakeitemLink)) <-- get localized name - format or not depending on the value returned by GetFishingLureInfo or format both the same to compare
(all you need to do this is in fisherman, file Baits.lua btw : all ids, the localized name function too)


but i think you are able to simply make a table lure[itemId] = lureindex, i'm pretty sure these indexes are stable because of the selection wheel.

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.
I changed my local variables after last post to
Lua Code:
  1. local defaults = {
  2.     data = {
  3.         FoulBaitLeft = 0,
  4.         FoulSBaitLeft = 0,
  5.         RiverBaitLeft = 0,
  6.         RiverSBaitLeft = 0,
  7.         OceanBaitLeft = 0,
  8.         OceanSBaitLeft = 0,
  9.         LakeBaitLeft = 0,
  10.         LakeSBaitLeft = 0,
  11.         GeneralBait = 0,
  12.     },
  13. },
so they became "local" for my entire addon instead of the one function
Edit: You are right about the local lureIndex = GetFishingLure() I just copied from circonian's example lol.

Last edited by SnowmanDK : 12/22/15 at 04:17 PM.
  Reply With Quote
12/22/15, 04:38 PM   #3
Wandamey
Guest
Posts: n/a
I was thinking you could avoid the loop by using the indexes directly, though it may look cleaner, it would bring nothing since you update all the values at the same time.

your way is more resistant against indexes variations too. Don't mind what i said.
  Reply With Quote
12/22/15, 04:48 PM   #4
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Originally Posted by Wandamey View Post
I was thinking you could avoid the loop by using the indexes directly, though it may look cleaner, it would bring nothing since you update all the values at the same time.

your way is more resistant against indexes variations too. Don't mind what i said.
Your input is still valued

Now I just need an event that is fired when I OPEN my map (by pressing 'M').
As it is now, it counts every time there is ANY change in my bag, which causes lag.

I did look into votan's example using
Lua Code:
  1. WORLD_MAP_SCENE:RegisterCallback("StateChange", WorldMapStateChanged)
  2. GAMEPAD_WORLD_MAP_SCENE:RegisterCallback("StateChange", WorldMapStateChanged)
but it only fires on map change, not when I open it.

Last edited by SnowmanDK : 12/22/15 at 04:50 PM.
  Reply With Quote
12/26/15, 09:37 PM   #5
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

ESOUI » Developer Discussions » General Authoring Discussion » How to detect when I have used some bait


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