Mercurial > wow > inventory
comparison ItemData.class.lua @ 76:958aba5f3297
Moved the group functions to the item data class.
Added a new subgroup under the general config group called ?extra? which will provide features such as database character removal and perhaps guild selecting.
Added a new custom .Print function to the addon object which takes two parameters: (string)text, (Color)color. The latter can be retrieved from the addon.Colors var (e.g. addon.Colors.Red).
The ItemId parameter of the ItemData class constructor is now optional.
author | Zerotorescue |
---|---|
date | Sat, 25 Dec 2010 22:07:07 +0100 |
parents | 8d11fc88ecab |
children |
comparison
equal
deleted
inserted
replaced
75:2127ab01ed4a | 76:958aba5f3297 |
---|---|
26 self.localCount = -3; | 26 self.localCount = -3; |
27 self.set = {}; | 27 self.set = {}; |
28 | 28 |
29 return self; | 29 return self; |
30 end | 30 end |
31 | |
32 function addon.ItemData:AddToGroup(groupName) | |
33 if self:InGroup() then | |
34 return false; | |
35 end | |
36 | |
37 if not addon.db.profile.groups[groupName].items then | |
38 addon.db.profile.groups[groupName].items = {}; | |
39 end | |
40 | |
41 -- Set this item | |
42 addon.db.profile.groups[groupName].items[self.id] = true; | |
43 | |
44 return true; | |
45 end | |
46 | |
47 -- To remove an item without groupname just do RemoveFromGroup(InGroup()), although providing the group name is a nice sanity check | |
48 function addon.ItemData:RemoveFromGroup(groupName) | |
49 if self:InGroup() ~= groupName then | |
50 return false; | |
51 end | |
52 | |
53 -- Unset this item | |
54 addon.db.profile.groups[groupName].items[self.id] = nil; | |
55 | |
56 return true; | |
57 end | |
58 | |
59 function addon.ItemData:InGroup() | |
60 -- Go through all groups to see if this item is already somewhere | |
61 for groupName, values in pairs(addon.db.profile.groups) do | |
62 if values.items and values.items[self.id] then | |
63 return groupName; | |
64 end | |
65 end | |
66 | |
67 return; | |
68 end |