1. Hello i have nearly not expirience in Lua, except 1 addon that i created when i write slashcmd command i get a frame that shows me in which level i can learn some skill, so i can avoid alt+tabbing, or going to trainer too often without need while leveling.

    For quite some time i have wanted to create addon that would help me with farming dungeons and some places outside dungeons(skinning, goldfarming, elemental items farming ect...)

    So i am not sure how to make it outside dungeon, but inside it should be relatively easy, so i decided to ask for help from expirienced people.

    I stumbled upon addon like this:

     local ghoulcd = CreateFrame("Frame", "XellosTimer", UIParent)
     ghoulcd:SetSize(40,24)
     ghoulcd:SetPoint("CENTER",0,100)
     ghoulcd:SetFrameStrata("HIGH")
     ghoulcd.t = ghoulcd:CreateTexture()
     ghoulcd.t:SetAllPoints()
     ghoulcd.t:SetTexture(0, 0, 0, .5)
     ghoulcd.t:Hide()
    
    
    
     local ghoultext = ghoulcd:CreateFontString(nil,"OVERLAY")
     ghoultext:SetFont("Fonts\\FRIZQT__.TTF", 20, "OUTLINE")
     ghoultext:SetPoint("CENTER", ghoulcd, "CENTER", 1, 0)
     ghoultext:SetTextColor(.913,.11,.11)
     ghoultext:Hide()
    
    
    
     local timeElapsed = 0, ghoultimer
    
     local function CD_Update()
       ghoulcd:SetScript("OnUpdate", function(self, elapsed)
         timeElapsed = timeElapsed + elapsed
         if ( timeElapsed >= 1 ) then
           timeElapsed = 0
           ghoultimer = 60 - (GetTime()-GetSpellCooldown(46584))
    
           --@Interval Start
             if (ghoultimer <= 0) then 
               ghoulcd.t:Hide()
               ghoultext:Hide()
               ghoulcd:SetScript("OnUpdate", nil)
             else
               ghoultext:SetText(format("%d",ghoultimer))
               ghoulcd.t:Show()
               ghoultext:Show()
             end
           --@Interval End
    
         end
       end)
     end
    
    
    
     ghoulcd:SetScript("OnEvent", function(self, event, sourceUnit, spellName)
       if (sourceUnit == "player" and spellName=="Raise Dead") then
         CD_Update()
       end
     end)
    
    
    
     ghoulcd:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
    
    
    
     ---- Set Movable
     local b = CreateFrame("Frame", nil, UIParent)
     b:SetSize(40,25)
     b:SetPoint("TOP", ghoulcd, "TOP", 0, 0)
     b:EnableMouse(true)
     ghoulcd:SetMovable(true)
     ghoulcd:SetUserPlaced(true)
     b:SetScript("OnMouseDown", function() ghoulcd:StartMoving() end)
     b:SetScript("OnMouseUp", function() ghoulcd:StopMovingOrSizing() end)
     b.t = b:CreateTexture()
     b:SetFrameStrata("HIGH")
     b.t:SetAllPoints()
     b.t:SetTexture(0, 0.5, 1)
     b.t:SetAlpha(0.8)
     b:Hide()
    
     SlashCmdList["XELLOSBAR"]=function() b[b:IsShown() and "Hide" or "Show"](b) end
     SLASH_XELLOSBAR1 = "/xb"
    
    [HTML tag <h92> removed: not allowed]

    Very very small and simple addon, in which i can work with maybe 1/10 of commands, while i understand about 80% of lines and commands.

    I was thinking of using this:

    timeElapsed = timeElapsed + elapsed
    

    within a shell of something like this:

     local function CD_Update()
       ghoulcd:SetScript("OnUpdate", function(self, elapsed)
       end
     end)
    

    I'm still working on how to accurately print numbers into

     local ghoulcd = CreateFrame("Frame", "XellosTimer", UIParent)
    

    this thing, but i'll work it out its not the big problem.

    Biggest problem is how do i change this:

     ghoulcd:SetScript("OnEvent", function(self, event, sourceUnit, spellName)
       if (sourceUnit == "player" and spellName=="Raise Dead") then
         CD_Update()
       end
     end)
    
    
    
     ghoulcd:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
    

    to an event that is called when i enter dungeon or raid. Just to clarify what i mean, i could imagine(cos i know nearly no commands:) something like this:

     ghoulcd:SetScript("OnEvent", function(self, event, eventname)
       if (eventname == "ENTERED_DUNGEON") then
         CD_Update()
       end
     end)
    

    and something similiar like:

     ghoulcd:SetScript("OnEvent", function(self, event, eventname)
       if (eventname == "EXITED_DUNGEON") then
         CD_Stop()
       end
     end)
    

    With another function inserted within addon called CD_Stop() which would stop timer and show message about some statistic like: "(%player) completed (%dungeonname) within (timeElapsed)" If possible to know how many bosses i killed and maybe in future even what loot i got - including greens(uncommons) and blues(rares) which are usable for disenchanting and some other stuff that sells well like zone drops and such.

    This info would be printed in message to myself(cos i dont know how to add this to library and i imagine it would be very hard) and i could use addon to copy message from chat and i'd put it in a txt file. In future of course if i would still have strenght i would like to learn how to put this info into library and make statistics and analysis for different zones/people groups/farming places - to know where i am doing better and which i should avoid.

    So biggest question is - is there such possiblity to call timer function OnEvent that i enter dungeon and stop timer when i exit it?

    I'm sorry that i wrote so much, i am doing this for the first time and i dont know how to start better. It was not easy for me to write all this, since i programmed stuff last time about 10 years ago when i was going to place for kids to learn QBasic and Pascal after school:) So i just write what i think basically, i hope you can understand at least half of it and any input will be apprecieted.

    Thanks in advance!

  2. You could use /eventtrace to see what events fire when you enter/leave a dungeon.

  3. Thanks i'll use that.