comparison Modules/Api.lua @ 95:63823b6b5e28

API: Added a way for other addons to register with ItemAuditor once it loads if they were loaded first and updated the example at the end of Api.lua.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Thu, 12 Aug 2010 00:54:00 -0700
parents cd00b87fad31
children 1fbbe3b53f6e
comparison
equal deleted inserted replaced
94:4ec8611d9466 95:63823b6b5e28
40 function IAapi.UnRegisterQueueDestination(name) 40 function IAapi.UnRegisterQueueDestination(name)
41 assert(type(name) == 'string', 'name must be the string that was used to register your addon.') 41 assert(type(name) == 'string', 'name must be the string that was used to register your addon.')
42 Crafting.UnRegisterQueueDestination(name) 42 Crafting.UnRegisterQueueDestination(name)
43 end 43 end
44 44
45 local function registerLoadedAddons()
46 return ItemAuditor_RegisterAPI and ItemAuditor_RegisterAPI()
47 end
48 registerLoadedAddons()
49
50
51 -- This is here so I have a second option in the menu and to serve as an example of
52 -- how to register your addon with ItemAuditor.
45 --@debug@ 53 --@debug@
46 -- This is here so I have a second option in the menu and to serve as an example. 54 local function RegisterWithItemAuditor()
47 local function testDestination(data) 55 local function testDestination(data)
48 ItemAuditor:Print('queue: '..data.recipeLink) 56 -- Replace this with a call to the methods you need in your addon
57 ItemAuditor:Print('queue: '..data.recipeLink)
58 end
59 -- Replace Echo with the name of your addon so it can be selected from /ia options
60 IAapi.RegisterQueueDestination('Echo', testDestination)
49 end 61 end
50 62
51 IAapi.RegisterQueueDestination('Echo', testDestination) 63 if IAapi then
64 RegisterWithItemAuditor()
65 else
66 -- make sure to save any other addon's function
67 local original = ItemAuditor_RegisterAPI
68 -- this should not be local so it replaces (or creates) the global function
69 function ItemAuditor_RegisterAPI()
70 RegisterWithItemAuditor()
71 -- if original has a value (function), this will run it
72 return original and original()
73 end
74 end
75
76
77
78
52 --@end-debug@ 79 --@end-debug@