Thread Tools Display Modes
12/20/15, 04:14 AM   #1
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
How to detect when I have used some bait

I am trying to add a tooltip to my fishing pins in Destinations and I have succeeded.
It reads the amount of bait suitable for that particular type of water, and adds it to the pin info.
My problem is, when I have used a bait, then it doesn't update to the new amount when I reopen my map.
Only if I change to another map does it update. That is because it is set to re-read bait info from my bag on map change.

Is there a way to detect I have used a bait, so I can get it to update the numbers left?

I have looked into both fishing events and map events, but can't seem to find any that can be used in this case... Or did I miss something?
  Reply With Quote
12/20/15, 10:25 AM   #2
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 578
Originally Posted by SnowmanDK View Post
I am trying to add a tooltip to my fishing pins in Destinations and I have succeeded.
It reads the amount of bait suitable for that particular type of water, and adds it to the pin info.
My problem is, when I have used a bait, then it doesn't update to the new amount when I reopen my map.
Only if I change to another map does it update. That is because it is set to re-read bait info from my bag on map change.

Is there a way to detect I have used a bait, so I can get it to update the numbers left?

I have looked into both fishing events and map events, but can't seem to find any that can be used in this case... Or did I miss something?
Hi SnowmanDK,

how you doing?

Plan A and B:
1. Maybe EVENT_INVENTORY_ITEM_USED is triggered?
2. EVENT_INVENTORY_SINGLE_SLOT_UPDATE is triggered for sure. May set a dirty flag in that event to re-read baits in custom pins tooltip creator callback.

CU
  Reply With Quote
12/20/15, 10:41 AM   #3
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Originally Posted by votan View Post
Hi SnowmanDK,

how you doing?

Plan A and B:
1. Maybe EVENT_INVENTORY_ITEM_USED is triggered?
2. EVENT_INVENTORY_SINGLE_SLOT_UPDATE is triggered for sure. May set a dirty flag in that event to re-read baits in custom pins tooltip creator callback.

CU
Thanks, I'll look at those
Update:
EVENT_INVENTORY_SINGLE_SLOT_UPDATE worked for me
I set it to update all fishing pins IF the change in the bag was in a fishing bait stack (checked using GetItemLink()).

Last edited by SnowmanDK : 12/20/15 at 11:15 AM.
  Reply With Quote
12/20/15, 11:50 AM   #4
Wandamey
Guest
Posts: n/a
or you could recount your stack right before displaying the tooltip with a Prehook "OnShow" ? what are the chances for the tooltip to be already on screen while the baits are depleted?

ZO_PreHook(yourtooltip, "OnShow", yourupdatefunc)

If your tooltip is personalized it would restrain the number of calls for sure.


(whoops forgot to say hi!)

actually it would be even savier do it on map display as you tried, but for that you should look at the SCENES functions, I can't tell exactly for this.

Last edited by Wandamey : 12/20/15 at 12:23 PM.
  Reply With Quote
12/20/15, 01:12 PM   #5
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Originally Posted by Wandamey View Post
or you could recount your stack right before displaying the tooltip with a Prehook "OnShow" ? what are the chances for the tooltip to be already on screen while the baits are depleted?

ZO_PreHook(yourtooltip, "OnShow", yourupdatefunc)

If your tooltip is personalized it would restrain the number of calls for sure.


(whoops forgot to say hi!)

actually it would be even savier do it on map display as you tried, but for that you should look at the SCENES functions, I can't tell exactly for this.
I think I'll check out your suggestions.
Even though EVENT_INVENTORY_SINGLE_SLOT_UPDATE works, and I did set it to only update when a bait stack changes, then it causes a small lag every time it updates, eg. you pick up bait or move/use bait. Not critical, but still...
  Reply With Quote
12/20/15, 01:51 PM   #6
Wandamey
Guest
Posts: n/a
yes you have to browse your bag each time, would be the same with the tooltips though I just got another idea:

you can do your own "popuptooltip" like this :
MyItemTooltip = WINDOW_MANAGER:CreateControlFromVirtual("MyItemTooltipName", parent , "ZO_ItemIconTooltip")

(if SetLink doesn't work with this try "ZO_PopupTooltip" in 3rd arg)

then you can anchor it exactly as you want with no risk to make a mistake with the original one and use a SetLink to generate the raw itemtooltip of your baits. it'll have the image and the description but no hooks from other addons. advantage of this : the number of possed items is already on it in the corner : bag and bank with no extra processing

the display would a bit overkill for just a number, but at least not the background processing. Maybe just stuck the popup in a corner and use the control to display whatever extra fancy info you need.

good luck!
  Reply With Quote
12/20/15, 02:11 PM   #7
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 578
Originally Posted by SnowmanDK View Post
I think I'll check out your suggestions.
Even though EVENT_INVENTORY_SINGLE_SLOT_UPDATE works, and I did set it to only update when a bait stack changes, then it causes a small lag every time it updates, eg. you pick up bait or move/use bait. Not critical, but still...
Jo, that's why I suggested to use a dirty flag, only.
Count the baits, once needed and cache until dirty flag is true again.
But there are many ways
  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