• 0

    posted a message on Need help with my debuff tracker
    Wow, thank you both for all of your help! :D
    Posted in: AddOn HELP!
  • 0

    posted a message on Need help with my debuff tracker
    Ok, I have added the XML file to my post. I don't think I'd be able to call the functions from the XML file if they were declared local. Should I perhaps add the prefix "FST_" to their name so they'd be called "FST_RegisterEvents" and "FST_EventHandler"? How would you do it? I'm pretty new to all of this so all your help is appreciated. :)
    Posted in: AddOn HELP!
  • 0

    posted a message on Need help with my debuff tracker
    I'm trying to make a simple AddOn that keeps track of Flame Shock on my target. I know that I could just download another AddOn such as TellMeWhen or NeedToKnow etc. but I'm doing this for learning purposes. Anyway, any suggestions how I would do this? This is what I've got so far, but it doesn't work the way I want it to. It displays the remaining time of the debuff every time it ticks, but it doesn't tick at exactly every second, so for example it might display: 24.00001, 22.0003, 19.458... or something like that.

    FlameShockTracker.xml
    <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ .. \FrameXML\UI.xsd">
    	<Script file="FlameShockTracker.lua" />
    	<Font name="FST_Default_Font" font="Interface\AddOns\FlameShockTracker\Fonts\arial.ttf" virtual="true" outline="normal">
    		<FontHeight>
    			<AbsValue val="30" />
    		</FontHeight>
    		<Color r="1" g="0" b="0" a="1" />
    		<Shadow>
    			<Offset x="0" y="0" />
    		</Shadow>
    	</Font>
    	<Frame name="FST_Main_Frame" parent="UIParent">
    		<Size>
    			<AbsDimension x="50" y="50" />
    		</Size>
    		<Anchors>
    			<Anchor point="center">
    				<Offset y="-150" />
    			</Anchor>
    		</Anchors>
    		<Layers>
    			<Layer>
    				<FontString name="FST_Main_FontString" inherits="FST_Default_Font" />
    			</Layer>
    		</Layers>
    		<Scripts>
    			<OnLoad function="RegisterEvents" />
    			<OnEvent function="EventHandler" />
    		</Scripts>
    	</Frame>
    </Ui>


    FlameShockTracker.lua
    function RegisterEvents (self)
    	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    end
    
    function EventHandler (self, event, ...)
    	if event == "COMBAT_LOG_EVENT_UNFILTERED" then
    		local playerGUID = UnitGUID("player")
    		local targetGUID = UnitGUID("target")
    		local timestamp, spellEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceFlags2, destGUID, destName, destFlags, destFlags2 = ...
    
    		if sourceGUID == playerGUID and destGUID == targetGUID and (spellEvent == "SPELL_AURA_APPLIED" or spellEvent == "SPELL_PERIODIC_DAMAGE") then
    			local expirationTime = select(7, UnitAura("target", "Flame Shock", nil, "PLAYER|HARMFUL"))
    
    			if expirationTime then
    				FST_Main_FontString:SetText(expirationTime - GetTime())
    			else
    				FST_Main_FontString:SetText()
    			end
    		end
    	end
    end


    TL; DR: How do I make a timer that tracks Flame Shock and ticks every 1 second?

    PS: English is not my native language so if I'm not making myself clear then don't hesitate to ask, I won't take offense.
    Posted in: AddOn HELP!
  • 0

    posted a message on Can't get XML Font to work
    Thank you! :)
    Posted in: AddOn HELP!
  • 0

    posted a message on Can't get XML Font to work
    HeilagurKraftur.toc:
    ## Interface: 50001
    ## Title: Heilagur kraftur
    HeilagurKraftur.xml


    HeilagurKraftur.xml:
    <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ .. \FrameXML\UI.xsd">
    	<Script file="HeilagurKraftur.lua" />
    	<Font name="Default_HK_Font" font="Fonts/arial.ttf" virtual="true">
    		<FontHeight>
    			<AbsValue val="30" />
    		</FontHeight>
    		<Color r="1" g="1" b="0" a="1" />
    		<Shadow>
    			<Offset x="0" y="0" />
    		</Shadow>
    	</Font>
    	<Frame name="HK_MainFrame" parent="UIParent">
    		<Size>
    			<AbsDimension x="50" y="50" />
    		</Size>
    		<Anchors>
    			<Anchor point="CENTER" />
    		</Anchors>
    		<Layers>
    			<Layer>
    				<FontString name="HK_DisplayText" inherits="Default_HK_Font" />
    			</Layer>
    		</Layers>
    		<Scripts>
    			<OnLoad function="HK_RegisterEvents" />
    			<OnEvent function="HK_EventHandler" />
    		</Scripts>
    	</Frame>
    </Ui>


    HeilagurKraftur.lua:
    function HK_RegisterEvents (self)
    	self:RegisterEvent("PLAYER_ENTERING_WORLD")
    	self:RegisterEvent("UNIT_POWER")
    end
    
    function HK_EventHandler (self, event, arg1, arg2)
    	if (event == "PLAYER_ENTERING_WORLD" or (event == "UNIT_POWER" and arg1 == "player" and arg2 == "HOLY_POWER")) then
    		HK_DisplayText:SetText(UnitPower("player", 9))
    	end
    end


    The error:
    Message: Interface\AddOns\HeilagurKraftur\HeilagurKraftur.lua:8: HK_DisplayText:SetText(): Font not set
    Time: 10/15/12 20:11:08
    Count: 1
    Stack: [C]: in function `SetText'
    Interface\AddOns\HeilagurKraftur\HeilagurKraftur.lua:8: in function <Interface\AddOns\HeilagurKraftur\HeilagurKraftur.lua:6>

    Locals: (*temporary) = HK_DisplayText {
    0 = <userdata>
    }
    (*temporary) = 0


    It is like the Font element's attribute, font, in HeilagurKraftur.xml, line 3, is not working. My AddOn's directory looks like this:

    HeilagurKraftur
         Fonts
              arial.ttf
         HeilagurKraftur.lua
         HeilagurKraftur.toc
         HeilagurKraftur.xml


    Can anyone figure out what I've done wrong? Any help will be greatly appreciated.

    Thanks in advance,
    Hallur
    Posted in: AddOn HELP!
  • To post a comment, please or register a new account.