comparison Turok/Modules/Timer/Status.lua @ 9:9400a0ff8540

Ugh Timer: - container update directionality - talent update iterates over a non-volatile table to carry out updates - index management steps organized - talentRow status implemented, returns the spell associated with the talent chosen from that row CombatLog: - sort out font controls and unbork arguments
author Nenue
date Sun, 21 Feb 2016 13:08:30 -0500
parents a9b8b0866ece
children
comparison
equal deleted inserted replaced
8:7790dff0fe13 9:9400a0ff8540
1 local _G, T = _G, Turok 1 local _G, T = _G, Turok
2 local mod = T.modules.TimerControl 2 local mod = T.modules.TimerControl
3 local P = mod.prototype 3 local P = mod.prototype
4 local GetInventoryItemID, GetItemInfo, GetInventoryItemTexture = GetInventoryItemID, GetItemInfo, GetInventoryItemTexture 4 local GetInventoryItemID, GetItemInfo, GetInventoryItemTexture = GetInventoryItemID, GetItemInfo, GetInventoryItemTexture
5 local GetSpellDescription, GetSpellInfo, GetSpellCharges = GetSpellDescription, GetSpellInfo, GetSpellCharges 5 local GetSpellDescription, GetSpellInfo, GetSpellCharges = GetSpellDescription, GetSpellInfo, GetSpellCharges
6 local GetTalentRowSelectionInfo = GetTalentRowSelectionInfo
7 local tinsert, type, tonumber, pairs, ipairs, unpack = tinsert, type, tonumber, pairs, ipairs, unpack 6 local tinsert, type, tonumber, pairs, ipairs, unpack = tinsert, type, tonumber, pairs, ipairs, unpack
8 local UnitGUID = UnitGUID 7 local UnitGUID = UnitGUID
9 local GetTalentInfo, GetTalentInfoByID, GetItemSpell, PaperDoll_IsEquippedSlot = GetTalentInfo, GetTalentInfoByID, GetItemSpell, PaperDoll_IsEquippedSlot 8 local GetTalentInfo, GetTalentInfoByID, GetItemSpell, PaperDoll_IsEquippedSlot = GetTalentInfo, GetTalentInfoByID, GetItemSpell, PaperDoll_IsEquippedSlot
10 local print = function(...) print('Timer', ...) end
11 print('Peep!', ...)
12
13 --@debug@ 9 --@debug@
14 local DEBUG = true 10 local DEBUG = true
15 --@end-debug@ 11 --@end-debug@
16 local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool 12 local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool
17 local print = function(...) 13 local print = function(...)
18 if not DEBUG then return end 14 if not DEBUG then return end
19 if _G.Devian and _G.DevianDB.workspace ~= 1 then 15 if _G.Devian and _G.DevianDB.workspace ~= 1 then
20 _G.print('Timer', ...) 16 _G.print('Timer', ...)
21 end 17 end
22 end 18 end
19 local tfprint = function(...)
20 if not DEBUG then return end
21 if _G.Devian and _G.DevianDB.workspace ~= 1 then
22 _G.print('TimerFocus', ...)
23 end
24 end
23 ------------------------------------------ 25 ------------------------------------------
24 --- Parameter Prototypes 26 --- Parameter Prototypes
25 27
26 local Timer_GetPrintHandler = function(self) 28 local Timer_GetPrintHandler = function(self)
27 return self.trace and function(...) 29 return self.trace and function(...)
28 print(...) 30 print(...)
29 _G.print('TimerFocus', ...) 31 tfprint( ...)
30 end or print 32 end or print
31 end 33 end
32 34
33 local Timer_UpdateIndex = function(self, key, value) 35 local Timer_UpdateIndex = function(self, key, value)
34 local print = Timer_GetPrintHandler(self) 36 local print = Timer_GetPrintHandler(self)
59 sfk[value] = #mfkv 61 sfk[value] = #mfkv
60 print(' *= self.frames['..cKey(key)..']['..cNum(value)..'] = ', sfk[value]) 62 print(' *= self.frames['..cKey(key)..']['..cNum(value)..'] = ', sfk[value])
61 end 63 end
62 end 64 end
63 65
66 --- update conditional cvars (i.e. talentRow(5) pulls up column 3, so cvars.x = args[talentRow][3].x)
67 local Timer_SetAttributeValues = function(self, key, value)
68 print(' ', cKey(key), 'sub-value =', cNum(value))
69 local sda = self.dvars.args
70 if sda and sda[key] then
71 print(cText(' conditional:'))
72 local dvals = (value and sda[key][value]) and sda[key][value] or sda[key].default
73 for k, v in pairs(dvals) do
74 print(cText(' '), 'cvars.'..cKey(k), '=', cWord(v))
75 self.cvars[k] = v
76 end
77 end
78 end
79
64 --- spellID 80 --- spellID
65 do 81 do
66 local spellID = P.status.spellID 82 local spellID = P.status.spellID
67 spellID.Init = function(self, spellID) 83 spellID.Init = function(self, spellID)
68 local print = Timer_GetPrintHandler(self) 84 local print = Timer_GetPrintHandler(self)
100 else 116 else
101 print(' ', cPink("spellID"), '=', 'not sure') 117 print(' ', cPink("spellID"), '=', 'not sure')
102 Timer_UpdateIndex(self, 'spellID', nil) 118 Timer_UpdateIndex(self, 'spellID', nil)
103 Timer_UpdateIndex(self, 'spellName', spellName) 119 Timer_UpdateIndex(self, 'spellName', spellName)
104 end 120 end
121 Timer_SetAttributeValues(self, 'spellName', spellID)
105 end 122 end
106 end 123 end
107 124
108 125
109 --- talentID 126 --- talentID
124 self.debug_info ('Talent not selected.') 141 self.debug_info ('Talent not selected.')
125 end 142 end
126 143
127 print(' ', cKey('talentID ('..cNum(self.talentID)..', '..cNum(T.specGroup)..'):'), self.spellName, self.talentSelected ) 144 print(' ', cKey('talentID ('..cNum(self.talentID)..', '..cNum(T.specGroup)..'):'), self.spellName, self.talentSelected )
128 Timer_UpdateIndex(self, 'talentID', talentID) 145 Timer_UpdateIndex(self, 'talentID', talentID)
129 146 Timer_SetAttributeValues(self, 'talentID', self.talentSelected and 1 or 'default')
130 end 147 end
131 end 148 end
132 149
133 --- talentRow - use whatever is in that row as data 150 --- talentRow - use whatever is in that row as data
134 do 151 do
135 local talentRow = P.status.talentRow 152 local talentRow = P.status.talentRow
136 talentRow.Init = function(self, row) 153 talentRow.Init = function(self, row)
137 local print = Timer_GetPrintHandler(self) 154 local print = Timer_GetPrintHandler(self)
138 self.talentRow = row 155 self.talentRow = row
139 local noSelect, talentID = GetTalentRowSelectionInfo(row) 156 local match
140 if noSelect then 157 for i = 1, 3 do
158 local talentID, _, _, selected = GetTalentInfo(row, i, T.specGroup)
159 if selected then
160 P.status.talentID.Init(self, talentID)
161 match = i
162 end
163 end
164
165 if not match then
141 self.disable = true 166 self.disable = true
142 self.debug_info("No talent selected in target row.") 167 self.debug_info("No talent selected in target row.")
143 else 168 end
144 P.status.talentID.Init(self, talentID)
145 end
146 print(' ', cKey('talentRow ('.. cNum(row).. ') ='), talentID or 'none')
147 Timer_UpdateIndex(self, 'talentRow', row) 169 Timer_UpdateIndex(self, 'talentRow', row)
170 Timer_SetAttributeValues(self, 'talentRow', match)
148 end 171 end
149 end 172 end
150 173
151 174
152 --- talentOffset 175 --- talentOffset
222 if not self.itemID then 245 if not self.itemID then
223 self.disable = true 246 self.disable = true
224 self.debug_info ('bad itemID value') 247 self.debug_info ('bad itemID value')
225 end 248 end
226 249
227 self.spellName = GetItemSpell(self.itemID) 250 local spellName = GetItemSpell(self.itemID)
228 251
229 if not self.spellName then 252 if not spellName then
230 self.disable = true 253 self.disable = true
231 self.debug_info('no spell detected') 254 self.debug_info('no spell detected')
232 else 255 if self.spellName then
233 if not (self.frames.spellName and self.frames.spellName[self.spellName]) then 256 self.spellName = nil
234 if not self.frames.spellName then
235 self.frames.spellName = {}
236 end
237
238 Timer_UpdateIndex(self, 'spellName', self.spellName)
239 end 257 end
240 end 258 end
259
260 Timer_UpdateIndex(self, 'spellName', spellName)
261 Timer_SetAttributeValues(self, 'itemID', spellName)
262
241 print(' ', cKey('itemID'), cNum(self.itemID), self.isEquipped)--@end-debug@ 263 print(' ', cKey('itemID'), cNum(self.itemID), self.isEquipped)--@end-debug@
242 end 264 end
243 end 265 end
244 266
245 do 267 do
247 inventoryID.type = 'status' 269 inventoryID.type = 'status'
248 inventoryID.Init = function(self, slot) 270 inventoryID.Init = function(self, slot)
249 local print = Timer_GetPrintHandler(self) 271 local print = Timer_GetPrintHandler(self)
250 272
251 self.inventoryID = slot 273 self.inventoryID = slot
252 self.itemID = GetInventoryItemID(self.dvars.unit, slot) 274 local itemID = GetInventoryItemID(self.dvars.unit, slot)
253 local name = GetItemInfo(self.itemID) 275 local name = GetItemInfo(itemID)
254 if not PaperDoll_IsEquippedSlot(slot) then 276 if not PaperDoll_IsEquippedSlot(slot) then
255 self.disable = true 277 self.disable = true
256 self.debug_info('slot un-equipped') 278 self.debug_info('slot un-equipped')
257 return 279 return
258 end 280 end
259 281
260 P.status.itemID.Init(self, self.itemID) 282 Timer_SetAttributeValues(self, 'inventoryID', itemID)
283 P.status.itemID.Init(self, itemID)
261 self.spellIcon = GetInventoryItemTexture(self.dvars.unit, slot) 284 self.spellIcon = GetInventoryItemTexture(self.dvars.unit, slot)
262 print(' ', cKey('inventoryID'), '=', '{'..cNum(self.inventoryID).. ' -> '.. cNum(self.itemID or 'no-equip').. '}') 285 print(' ', cKey('inventoryID'), '=', '{'..cNum(self.inventoryID).. ' -> '.. cNum(self.itemID or 'no-equip').. '}')
263 end 286 end
264 end 287 end
265 288