the simple version is that global variables that you indicate in your .toc will get saved in whatever state they're in at logout/reload (after PLAYER_LEAVING_WORLD, etc. fire, so you can change them at the last second if you want to).
they are then restored after your addon is loaded. note that the *after* means that OnLoad handlers, etc. will run before the saved variables are loaded (see the events ADDON_LOADED and VARIABLES_LOADED)
|