Thread Tools Display Modes
04/26/15, 10:32 AM   #1
Bl4ck M4ch!n3
 
Bl4ck M4ch!n3's Avatar
Join Date: Apr 2015
Posts: 4
Logout-Events

Hi there!

I'm writing my first AddOn and i'm new to Lua, so there is a lot to learn :-)

My AddOn tracks a couple of things which i'm saving in the SavedVariables-file. This is working pretty well, but it happens way too often in my opinion. I've already used the Search Forums-function but i only found the EVENT_MANAGER:RegisterForUpdate-method. That's a nice start but i need to know when the user wants to logout. So, is there an event which gets fired when the user wants to logout/quit?!

Greetings!
  Reply With Quote
04/26/15, 10:52 AM   #2
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
Why "it happens way too often in my opinion" ?

If you are absolutly sure an action MUST to be done at logout and not at quit/reloadui, you can :

Lua Code:
  1. -- PreHook ReloadUI, LogOut & Quit
  2.     ZO_PreHook("ReloadUI", function() ...... end)
  3.     ZO_PreHook("Logout", function() .... end)  
  4.     ZO_PreHook("Quit", function() ... end)

PS : I clearly think you don't have to do this. SavedVars works well like without the need of modifying it.
  Reply With Quote
04/26/15, 11:33 AM   #3
Bl4ck M4ch!n3
 
Bl4ck M4ch!n3's Avatar
Join Date: Apr 2015
Posts: 4
That looks promising, thanks!

Why i think it happens to often? I hope i got that whole "SavedVariables"-stuff right.

For example :
AddOnExampleName.savedValues = ZO_SavedVars:New(........)

So, everytime i write something to AddOnExampleName.savedValues the SavedVariables-file is updated, right?
If it's just like this, then its happening too often. Because i call a method which is saving a couple of things at the following events:

EVENT_MONEY_UPDATE
EVENT_LOOT_RECEIVED
EVENT_INVENTORY_ITEM_USED
EVENT_INVENTORY_ITEM_DESTROYED
EVENT_INVENTORY_FULL_UPDATE
EVENT_INVENTORY_SINGLE_SLOT_UPDATE
EVENT_PLAYER_DEAD
EVENT_PLAYER_ALIVE
EVENT_EXPERIENCE_GAIN
EVENT_EXPERIENCE_GAIN_DISCOVERY
EVENT_EXPERIENCE_UPDATE

Maybe there is a event which is unnecessary? I assume its too often, but maybe i'm just a bit sensitive?
I just want to reduce the amount of calls. So i thought about saving those things if the user logs out of the game.

If i preHook the "Logout" will it work like this?
ZO_PreHook("Logout", AddOnExample.SaveThings())

Thanks in advance and sorry for my bad english!

Greetings
  Reply With Quote
04/26/15, 11:39 AM   #4
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
Originally Posted by Bl4ck M4ch!n3 View Post
That looks promising, thanks!

Why i think it happens to often? I hope i got that whole "SavedVariables"-stuff right.

For example :
AddOnExampleName.savedValues = ZO_SavedVars:New(........)

So, everytime i write something to AddOnExampleName.savedValues the SavedVariables-file is updated, right?

Thanks in advance and sorry for my bad english!

Greetings
No, SavedVar file is only writed on ReloadUI & LogOut, Quit and clean kick by game.

Per exemple, if you write something in your AddOnExampleName.savedValues, than have a crash 30min laters, your modification won't be stored.
  Reply With Quote
04/26/15, 12:19 PM   #5
Bl4ck M4ch!n3
 
Bl4ck M4ch!n3's Avatar
Join Date: Apr 2015
Posts: 4
Originally Posted by Ayantir View Post
No, SavedVar file is only writed on ReloadUI & LogOut, Quit and clean kick by game
Thats exactly what i wanted to achive, perfect! Thanks for clearing that up :-)

Originally Posted by Ayantir View Post
Per exemple, if you write something in your AddOnExampleName.savedValues, than have a crash 30min laters, your modification won't be stored.
Is there any possibility to store those values manually? Like an autosave-feature using the RegisterForUpdate-method?

Thanks so far!
  Reply With Quote
04/26/15, 12:37 PM   #6
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
As we got no I/O functionailty to read and write files I'd say: NO.
You'll have to do a ReloadUI() function call manually to save the vars and the user interface will be reloaded then.
You could do this with a timer and do it every 10 minutes but I think it's annyoing and if this happens during you are in a dungeon etc.... I think you won't like it
  Reply With Quote
04/26/15, 01:24 PM   #7
Bl4ck M4ch!n3
 
Bl4ck M4ch!n3's Avatar
Join Date: Apr 2015
Posts: 4
Originally Posted by Baertram View Post
You could do this with a timer and do it every 10 minutes but I think it's annyoing and if this happens during you are in a dungeon etc.... I think you won't like it
Yeah you're right

So i'll leave it like it is. Thank you both very much! Have a nice evening!

Greetings
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » Logout-Events


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