View Single Post
04-07-22, 12:35 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
Most addons rely on updating when things happen in-game. They are notified of these "happenings" through an event system.

If you just put code in a .lua file withouot setting up a method to listen for the events you are interested in, then the code runs just once when the .lua file is loaded by the addon system (while the bar scrolls across the bottom of you screen) and never again.

The extra code I added, registers to listen for the PLAYER_LOGIN event that fires once after all initial addons have loaded and the "UNIT_INVENTORY_CHANGED" event for the player unit (you) see for information on this event

It also sets up the OnEvent (listener) script do do what needs to be done when those events are sent to the addon. Because it runs the same code for all events registerd (and ony the regiistered events will be sent), the script doesn't have to be specific about what to do for each event.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote