comparison Modules/Api.lua @ 70:3930518cb8d9

Added a public API so other addon developers can register themselves as a queue destination and added a UI so users can select that destination.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Wed, 28 Jul 2010 22:19:38 -0700
parents e92a5adf75bf
children cd00b87fad31
comparison
equal deleted inserted replaced
69:4ae431c98059 70:3930518cb8d9
22 profitable item you could use this: 22 profitable item you could use this:
23 23
24 IAapi.RegisterCraftingDecider('Five', function() return 5 end) 24 IAapi.RegisterCraftingDecider('Five', function() return 5 end)
25 ]] 25 ]]
26 function IAapi.RegisterCraftingDecider(name, decider) 26 function IAapi.RegisterCraftingDecider(name, decider)
27 assert(type(name) == 'string', 'name must be a string to identify your addon. This will be displayed to the user.')
28 assert(type(destination) == 'function', 'decider must be a function.')
27 Crafting.RegisterCraftingDecider(name, decider) 29 Crafting.RegisterCraftingDecider(name, decider)
28 end 30 end
29 31
32 function IAapi.RegisterQueueDestination(name, destination)
33 assert(type(name) == 'string', 'name must be a string to identify your addon. This will be displayed to the user.')
34 assert(type(destination) == 'function', 'destination must be a function that will be called for each item when exporting the queue.')
35
36 Crafting.RegisterQueueDestination(name, destination)
37 end
30 38
39 function IAapi.UnRegisterQueueDestination(name)
40 assert(type(name) == 'string', 'name must be the string that was used to register your addon.')
41 Crafting.UnRegisterQueueDestination(name)
42 end
43
44 --@debug@
45 -- This is here so I have a second option in the menu and to serve as an example.
46 local function testDestination(data)
47 ItemAuditor:Print('queue: '..data.recipeLink)
48 end
49
50 IAapi.RegisterQueueDestination('Echo', testDestination)
51 --@end-debug@