02-08-10, 05:55 AM | #1 |
Newb Issue
ive been trying to write my first ever addon with ouf, but ive hit some issues pretty early, its only supposed to show debuffs at the moment, which it does, but i want a text timer on it which doesnt seem to work, heres my code currently if anyone can see where im going wrong
Code:
local function mylayout(self, event, unit) -- dimensions. self:SetHeight(40) self:SetWidth(240) -- Debuffz bar. local deebeez = CreateFrame("Frame", nil, self) deebeez:SetHeight(40) deebeez:SetWidth(240) deebeez:SetPoint("TOPLEFT", 0, 0) self.Debuffs = deebeez self.Debuffs:SetPoint("TOPLEFT", self, "BOTTOMLEFT", -1, -8) self.Debuffs.initialAnchor = "TOPLEFT" self.Debuffs.onlyShowPlayer = true self.Debuffs:SetWidth(44 * 6) self.Debuffs.size = 40 self.Debuffs.spacing = 4 --self.Debuffs.disableCooldown = true self.PostUpdateAuraIcon = imbadatlua end oUF:RegisterStyle("ouf_mikerockz", mylayout) oUF:SetActiveStyle("ouf_mikerockz") oUF:Spawn("target", "oUF_Layout_MikesTargetFrame"):SetPoint("CENTER", -455, 0) local imbadatlua = function(self,elapsed) if self.timeLeft > 0 then local time = FormatTime(self.timeLeft) self.remaining:SetText(time) end end Last edited by hairy_palms : 02-08-10 at 06:01 AM. |
|
02-08-10, 06:16 AM | #2 | |
and another question, doesn't "self,elapsed" has to be "self.elapsed"? (with a dot) Those are the things that kind of look strange to me, but me being a newbie at lua as well, it might just be my fault ^^. There's bound to be a lua pro commenting as well quickly enough Last edited by contramundi : 02-08-10 at 06:19 AM. |
||
02-08-10, 06:53 AM | #3 |
hmm u might be right, should i call self.timeleft from UnitAura("Target", index, "HARMFUL")?
the function Code:
function(self,elapsed) |
|
02-08-10, 08:14 AM | #4 |
I have just briefly run through aura.lua so I may be off but:
PostUpdateAuraIcon sends the following arguments: object, icons, unit, icon, index, offset, filter, isDebuff. In your imbadatlua function you are referring object with self, thus self.timeLeft and self.remaining are undefined fields. Unless SetCooldown does add those automatically, they would be undefined even if you were referring the correct frame. In any case, since cooldown is enabled, you are better off just installing OmniCC and let it create and update the strings you are looking for. |
|
02-08-10, 10:54 AM | #5 |
omniCC doesnt do what i want, and cooldowns only commented out untill i can get the text to show up, besides, im trying to make a simple target debuff tracker partly as a learning exercise and just installing another addon wont help that :P
but anyway, ive been lookin at it some more and i think ive made progress but still no cigar im calling it with UnitDebuff, im calling VT directly just for testing purposes. Code:
local function mylayout(self, event, unit) -- dimensions. self:SetHeight(40) self:SetWidth(240) -- Debuffz bar. local deebeez = CreateFrame("Frame", nil, self) deebeez:SetHeight(40) deebeez:SetWidth(240) deebeez:SetPoint("TOPLEFT", 0, 0) self.Debuffs = deebeez self.Debuffs:SetPoint("TOPLEFT", self, "BOTTOMLEFT", -1, -8) self.Debuffs.initialAnchor = "TOPLEFT" self.Debuffs.onlyShowPlayer = true self.Debuffs:SetWidth(44 * 6) self.Debuffs.size = 40 self.Debuffs.spacing = 4 --self.Debuffs.disableCooldown = true self.PostUpdateAuraIcon = imbadatlua end oUF:RegisterStyle("ouf_mikerockz", mylayout) oUF:SetActiveStyle("ouf_mikerockz") oUF:Spawn("target", "oUF_Layout_MikesTargetFrame"):SetPoint("CENTER", -455, 0) local imbadatlua = function(self,elapsed) local name, _, _, _, _, duration, expiry, unitCaster = UnitDebuff("target","Vampiric Touch") self.timeLeft = expiry self.remaining = duration self.remaining:SetText(self.timeLeft) self.remaining:SetTextColor(0.84, 0.75, 0.65) end |
|
02-08-10, 12:53 PM | #6 |
Code:
local FormatTime = function(s) if s >= 86400 then return format('|cffffffff%d|r'..hexclasscolor..'d|r', floor(s/86400 + 0.5)), s % 86400 elseif s >= 3600 then return format('|cffffffff%d|r'..hexclasscolor..'h|r', floor(s/3600 + 0.5)), s % 3600 elseif s >= 60 then return format('|cffffffff%d|r'..hexclasscolor..'m|r', floor(s/60 + 0.5)), s % 60 end return floor(s + 0.5), (s * 100 - floor(s * 100))/100 end local CreateAuraTimer = function(self,elapsed) if self.timeLeft then self.elapsed = (self.elapsed or 0) + elapsed if self.elapsed >= 0.1 then if not self.first then self.timeLeft = self.timeLeft - self.elapsed else self.timeLeft = self.timeLeft - GetTime() self.first = false end if self.timeLeft > 0 then local atime = FormatTime(self.timeLeft) self.remaining:SetText(atime) else self.remaining:Hide() self:SetScript('OnUpdate', nil) end self.elapsed = 0 end end end local CustomAuraFilter = function(icons, unit, icon, name, rank, texture, count, dtype, duration, timeLeft, caster) local isPlayer if(caster == 'player' or caster == 'vehicle') then isPlayer = true end if((icons.onlyShowPlayer and isPlayer) or (not icons.onlyShowPlayer and name)) then icon.isPlayer = isPlayer icon.owner = caster -- We set it to math.huge, because it lasts until cancelled. if(timeLeft == 0) then icon.timeLeft = math.huge else icon.timeLeft = timeLeft end return true end end local sort = function(a, b) return a.timeLeft > b.timeLeft end local PreAuraSetPosition = function(self, auras, max) table.sort(auras, sort) end local CancelAura = function(self, button) if (button == 'RightButton' and not self.debuff) then CancelUnitBuff('player', self:GetID()) end end local function PostCreateAuraIcon(self, button, icons, index, debuff) button.count:SetFont(db.font, db.fontsize, 'OUTLINE') button.count:SetPoint('TOPRIGHT', button, 'TOPRIGHT', -1, 8) icons.disableCooldown = true icons.showDebuffType = true button.cd:SetReverse() icons.noOCC = true button.overlay:SetTexture(db.border) button.overlay:SetTexCoord(0, 1, 0, 1) button.overlay.Hide = function(self) self:SetVertexColor(0, 0, 0) end if icons ~= self.Enchant then if (self.unit == 'player') then button:SetScript('OnMouseUp', CancelAura) end else button.overlay:SetVertexColor(RAID_CLASS_COLORS[class].r,RAID_CLASS_COLORS[class].g,RAID_CLASS_COLORS[class].b) button.cd:Hide() end button.bg = CreateFrame('Frame', nil, button) button.bg:SetPoint('TOPLEFT', button, 'TOPLEFT', -4, 4) button.bg:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT', 4, -4) button.bg:SetFrameStrata('LOW') button.bg:SetBackdrop(db.frameBD) button.bg:SetBackdropColor(0, 0, 0, 0) button.bg:SetBackdropBorderColor(0, 0, 0,0.5) local remaining = button:CreateFontString(nil, 'OVERLAY') remaining:SetPoint('BOTTOM') remaining:SetFont(db.font, db.fontsize+1, 'OUTLINE') remaining:SetTextColor(1, 1, 1) button.remaining = remaining end local function PostUpdateAuraIcon(self, icons, unit, icon, index, offset, filter, duration, timeLeft) local name, _, _, _, _, duration, timeLeft, unitCaster, _ = UnitAura(unit, index, icon.filter) if UnitCanAttack('player', unit) then if unitCaster == 'player' or unitCaster == 'pet' or unitCaster == 'vehicle' then if duration and duration > 0 then icon.cd:Show() else icon.cd:Hide() end else icon.icon:SetDesaturated(true) icon.cd:Hide() end else if duration and duration > 0 then icon.cd:Show() else icon.cd:Hide() end end if duration and duration > 0 then icon.remaining:Show() else icon.remaining:Hide() end icon.duration = duration icon.first = true icon:SetScript('OnUpdate', CreateAuraTimer) end Just some code changes, as i'm not an author myself. But you must define remaining in a PostCreateAuraIcon for your code to work. |
|
WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Newb Issue |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|