View Single Post
11-08-10, 02:01 AM   #10
Taroven
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 49
We're checking the contents of a table, not setting up an automatic indexing metamethod. Two completely different things you're thinking there. Besides, all ADDON_LOADED events are visible to all addons, the name or load order of the one checking shouldn't generally matter.

Here's how the earlier example code works. Let's say I had an addon with the following structure:
Code:
metaAddon.toc
metaAddon.lua
1.lua
2.lua
3.lua
4.lua
5.lua
Within each file is the first few lines of the example code, adding an entry to the loadedFiles entry in the addon's namespace table. Within metaAddon.lua is the rest of the code, checking that loadedFiles entry and doing stuff depending on what it finds.

Here's what the table would look like.
Code:
ns.loadedFiles = {
    1 = true,
    2 = true,
    3 = true,
    4 = true,
    5 = true,
}
That would let metaAddon.lua know if, say, a user deleted 4.lua. It might make something different happen depending on which files are present (like, if I added foo.lua, the addon could use a different function than normal for something complicated). It will not have any information regarding what files were loaded in Recount or Pitbull, because that's not what it was designed for.

It isn't meant to work with other addons at all - It's meant to keep track of which files within that specific addon are loaded. I went with the most obviously useful route, since Sideshow didn't specify - There's plenty of other tools for checking other addons, but not much in the way of checking for existence of files within your own.
__________________
Former author of EventHorizon Continued and Other Releases.

Last edited by Taroven : 11-08-10 at 02:11 AM. Reason: Code tags are awesome.
  Reply With Quote