Reply
Thread Tools Display Modes
Unread 04-01-11, 10:45 AM   #1
Julchen
A Deviate Faerie Dragon
Join Date: Dec 2009
Posts: 17
Rapture Tracking Problem

Hey i want to write a small AddOn to Track the Rapture CD for Priests. But my Problem is that i dont unterstand the lua code very well so it doesnt work right know. Can Anyone give me a hint how to solve the problem?!

Code:
function Foo_OnLoad(self)
  self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end

function Foo_OnEvent(self, event, ...)

	local timestamp, type, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags,  -- arg1  to arg8
    spellId, spellName, spellSchool,                                                          -- arg9  to arg11
    amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing = ... -- arg12 to arg20

  if (event == "COMBAT_LOG_EVENT_UNFILTERED") then
    if (type == "SPELL_ENERGIZE") then
		
		local spellId, spellName, spellSchool, amount, powerType = ...
		local player_name = UnitName("player")
		if destName == player_name and sourceName == player_name and spellId == 47755 then
		
		print("TESTESTESTESTEST")
	  
		end
    end
  end
end

local f = CreateFrame("Frame", "Foo_Frame")
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
f:SetScript("OnEvent", Foo_OnEvent)
Julchen is offline   Reply With Quote
Unread 04-01-11, 12:06 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 9,554
Before reading much further into your code... Is this all of it? When do you call your Foo_OnLoad() function?

/edit: nvm... I see you register the event again at the bottom anyway. hmmm

/edit2: You're assigning the ... twice
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh


Last edited by Seerah : 04-01-11 at 12:09 PM.
Seerah is offline   Reply With Quote
Unread 04-01-11, 12:31 PM   #3
Julchen
A Deviate Faerie Dragon
Join Date: Dec 2009
Posts: 17
Its all of the code - just copied from wowpedia example and changed it a bit so i should roughly work without any package... the events are hmm from Ignela's Rapture but its ace and i am not familiar with ace

This is the ace code of Ignela's Rapture
Code:
Rapture = LibStub("AceAddon-3.0"):NewAddon("Rapture", "AceConsole-3.0", "AceEvent-3.0")
RaptureGUI = LibStub("AceGUI-3.0")
local rapmedia = LibStub("LibSharedMedia-3.0")
local rapcandy = LibStub("LibCandyBar-3.0")
local db

local defaults = {
    profile = {
        scale = 1.0,
        xpos = 0,
        ypos = 0,
        colorr = 0, 
        colorg = 0.5, 
        colorb = 1, 
        colora = 1,        
        bgcolorr = 0, 
        bgcolorg = 0.5, 
        bgcolorb = 1, 
        bgcolora = 0.5,
        width = 200,
        height = 19,
        texture = "Blizzard",
        font = "Friz Quadrata TT",
        fontscale = 12,
        border = "Blizzard Dialog",
        bordersize = 16,
        borderinset = 16,
        borderheight = 23,
        borderwidth = 203,
        outline = 4,
		alignment = "LEFT",
		valignment = "CENTER",
		labelinput = "Rapture Cooldown",
		soundenable = true,
		frametime = 6,
		fadetime = 0.5,
		framelabelinput = "Rapture ready!",
		framefont = "Friz Quadrata TT",
		framexpos = 0,
		frameypox = 0,
		framefontscale = 24,
		framecolorr = 1,
		framecolorg = 1,
		framecolorb = 1,
		frameenable = true,
		},
}

local options = {
  type = "group",
  childGroups = "tab",
  args = {
        info = {
		  order = 1,
          name = "Info",
          desc = "Shows info about the addon",
          type = 'execute',
          func = function()
            Rapture:Print("This addon shows a neat bar too see how long cooldown is left on your rapture ability. Made by Ingela @ Twilight's Hammer(EU)")
          end,
        },
        test = {
		  order = 2,
          name = "Run Bar",
          desc = "Test rapture cooldown bar",
          type = 'execute',
          func = function()
          Rapture:Runbar()
          end,
        },
    bar = {
      type = "group",
      name = "Bar Options",
      args = {
        barposdesc = {
          order = 1,
          type = "description",
          name = "Bar positioning\n",
          cmdHidden = true
        },
        xpos = {
          order = 3,
          name = "X",
          desc = "Change horizontal position",
          type = 'range',
          min = -500,
          max = 500,
          step = 1,
          get = function(info) return db.xpos end,
          set = function(info, x) 
          db.xpos = x
          Rapture:Runtestbar()
          end,
        },
        ypos = {
          order = 6,
          name = "Y",
          desc = "Change veritcal position",
          type = 'range',
          min = -500,
          max = 500,
          step = 1,
          get = function(info) return db.ypos end,
          set = function(info, y) 
          db.ypos = y
          Rapture:Runtestbar()
          end,
          },
         nudgeright = {
          order = 4,
          name = "Right",
          desc = "Nudge right once",
          type = 'execute',
          get = function(info) return db.xpos end,
          func = function() 
          db.xpos = db.xpos + 1
          Rapture:Runtestbar()
          end,
         },
         nudgeleft = {
          order = 2,
          name = "Left",
          desc = "Nudge left once",
          type = 'execute',
          get = function(info) return db.xpos end,
          func = function() 
          db.xpos = db.xpos - 1
          Rapture:Runtestbar()
          end,
         },
         nudgeup = {
          order = 5,
          name = "Up",
          desc = "Nudge up once",
          type = 'execute',
          get = function(info) return db.ypos end,
          func = function() 
          db.ypos = db.ypos + 1
          Rapture:Runtestbar()
          end,
         },
         nudgedown = {
          order = 7,
          name = "Down",
          desc = "Nudge down once",
          type = 'execute',
          get = function(info) return db.ypos end,
          func = function() 
          db.ypos = db.ypos - 1
          Rapture:Runtestbar()
          end,
         },
        scaledesc = {
          order = 9,
          type = "description",
          name = "\n\nBar settings\n",
          cmdHidden = true
        },
        scale = {
          order = 10,
          name = "Scale",
          desc = "Set scale",
          type = 'range',
          min = 0.5,
          max = 2,
          step = 0.1,
          get = function(info) return db.scale end,
          set = function(info, s) 
          db.scale = s
          Rapture:Runtestbar()
          end,
        },
        width = {
          order = 11,
          name = "Width",
          desc = "Set width",
          type = 'range',
          min = 10,
          max = 600,
          step = 1,
          get = function(info) return db.width end,
          set = function(info, w) 
          db.width = w
          Rapture:Runtestbar()
          end,
        },
        height = {
          order = 12,
          name = "Height",
          desc = "Set height",
          type = 'range',
          min = 1,
          max = 60,
          step = 1,
          get = function(info) return db.height end,
          set = function(info, h) 
          db.height = h
          Rapture:Runtestbar()
          end,
        },
		textstuff = {
          order = 15,
          type = "description",
          name = "\n\nText settings\n",
          cmdHidden = true
        },
        texture = {
          order = 14,
          type = "select",
          name = "Texture",
          desc = "Set the statusbar texture.",
          values = rapmedia:HashTable("statusbar"),
          dialogControl = "LSM30_Statusbar",
          get = function(info) return db.texture end,
          set = function(info, text) 
          db.texture = text
          Rapture:Runtestbar()
          end,
        },
        font = {
          order = 16,
          type = "select",
          name = "Font",
          desc = "Set the font.",
          values = rapmedia:HashTable("font"),
          dialogControl = "LSM30_Font",
          get = function(info) return db.font end,
          set = function(info, f) 
          db.font = f
          Rapture:Runtestbar()
          end,
        },
        fontscale = {
          order = 17,
          name = "Font Scale",
          desc = "Set the font scale",
          type = 'range',
          min = 1,
          max = 50,
          step = 1,
          get = function(info) return db.fontscale end,
          set = function(info, fontsc) 
          db.fontscale = fontsc
          Rapture:Runtestbar()
          end,
        },
        outline = {
          order = 18,
          name = "Outline",
          desc = "Outline",
          type = 'select',
          values = {["OUTLINE"]="Outline", ["THICKOUTLINE"]="Thickoutline", ["MONOCHROME"]="Monochrome", ["NONE"]="None"},
          get = function(info) return db.outline end,
          set = function(info, line)
          db.outline = line
          Rapture:Runtestbar()
          end,
        },
		alignment = {
          order = 19,
          name = "Text alignment",
          desc = "Text alignment",
          type = 'select',
          values = {["LEFT"]="Left", ["CENTER"]="Center", ["Right"]="Right"},
          get = function(info) return db.alignment end,
          set = function(info, line)
          db.alignment = line
          Rapture:Runtestbar()
          end,
        },
		labelinput = {
          order = 20,
          name = "Label text",
          desc = "Label text",
          type = 'input',
          get = function(info) return db.labelinput end,
          set = function(info, line)
          db.labelinput = line
          Rapture:Runtestbar()
          end,
        },
--[[        borderdesc = {
          order = 16,
          type = "description",
          name = "\n\nBorder Options\n",
          cmdHidden = true
        },
        border = {
          order = 17,
          type = "select",
          name = "Border",
          desc = "Border",
          dialogControl = 'LSM30_Border',
          values = rapmedia:HashTable("border"),
          get = function(info) return db.border end,
          set = function(info, b) 
          db.border = b
          Rapture:Runbar()
          end,
        }, 
        borderSize = {
          order = 18,
          type = "range",
          name = "Bordersize",
          desc = "Border size",
          min = 4,
          max = 24,
          step = 1,
          get = function(info) return db.bordersize end,
          set = function(info, bsize) 
          db.bordersize = bsize
          Rapture:Runbar()
          end,
        },
        borderInset = {
          order = 19,
          type = "range",
          name = "Borderinset",
          desc = "Border inset",
          min = -25,
          max = 25,
          step = 1,
          get = function(info) return db.borderinset end,
          set = function(info, bins) 
          db.borderinset = bins
          Rapture:Runbar()
          end,
        },
        borderwidth = {
          order = 20,
          name = "Border width",
          desc = "Set border width",
          type = 'range',
          min = 10,
          max = 600,
          step = 1,
          get = function(info) return db.borderwidth end,
          set = function(info, bw) 
          db.borderwidth = bw
          Rapture:Runbar()
          end,
        },
        borderheight = {
          order = 21,
          name = "Border height",
          desc = "Set border height",
          type = 'range',
          min = 1,
          max = 60,
          step = 1,
          get = function(info) return db.borderheight end,
          set = function(info, bh) 
          db.borderheight = bh
          Rapture:Runbar()
          end,
        },]]
      },
    },
    colors = {
      type = "group",
      name = "Bar Colors",
      args = {
          barcolordesc = {
          order = 1,
          type = "header",
          name = "Bar color\n",
          cmdHidden = true
        },
        barcolor = {
          order = 2,
          name = "Bar color",
          desc = "Set color",
          type = 'color',
          hasAlpha = true,
          get = function(info) return db.colorr, db.colorg, db.colorb, db.colora end,
          set = function(info, r, g, b, a)
          db.colorr, db.colorg, db.colorb, db.colora = r, g, b, a
          Rapture:Runtestbar()
          end,
        },
        barcolorrgbadesc = {
          order = 3,
          type = "description",
          name = "\n\nRGBA changer\n",
          cmdHidden = true
        },
        barR = {
          order = 4,
          name = "Red",
          desc = "Set red color",
          type = 'range',
          min = 0,
          max = 1,
          step = 0.01,
          get = function(info) return db.colorr end,
          set = function(info, r)
          db.colorr = r
          Rapture:Runtestbar()
          end,
        },
        barG = {
          order = 5,
          name = "Green",
          desc = "Set green color",
          type = 'range',
          min = 0,
          max = 1,
          step = 0.01,
          get = function(info) return db.colorg end,
          set = function(info, g)
          db.colorg = g
          Rapture:Runtestbar()
          end,
        },
        barB = {
          order = 6,
          name = "Blue",
          desc = "Set blue color",
          type = 'range',
          min = 0,
          max = 1,
          step = 0.01,
          get = function(info) return db.colorb end,
          set = function(info, b)
          db.colorb = b
          Rapture:Runtestbar()
          end,
        },
        barA = {
          order = 7,
          name = "Alpha",
          desc = "Set the alpha",
          type = 'range',
          min = 0,
          max = 1,
          step = 0.01,
          get = function(info) return db.colora end,
          set = function(info, a)
          db.colora = a
          Rapture:Runtestbar()
          end,
        },
        bgcolordesc = {
          order = 9,
          type = "header",
          name = "Bar background color\n",
          cmdHidden = true
        },
        bgcolor = {
          order = 10,
          name = "Bar background color",
          desc = "Set color",
          type = 'color',
          hasAlpha = true,
          get = function(info) return db.bgcolorr, db.bgcolorg, db.bgcolorb, db.bgcolora end,
          set = function(info, bgr, bgg, bgb, bga)
          db.bgcolorr, db.bgcolorg, db.bgcolorb, db.bgcolora = bgr, bgg, bgb, bga
          Rapture:Runtestbar()
          end,
        },
        bgcolorrgbadesc = {
          order = 11,
          type = "description",
          name = "\n\nRGBA changer\n",
          cmdHidden = true
        },
        bgR = {
          order = 12,
          name = "Red",
          desc = "Set red color",
          type = 'range',
          min = 0,
          max = 1,
          step = 0.01,
          get = function(info) return db.bgcolorr end,
          set = function(info, bgr)
          db.bgcolorr = bgr
          Rapture:Runtestbar()
          end,
        },
        bgG = {
          order = 13,
          name = "Green",
          desc = "Set green color",
          type = 'range',
          min = 0,
          max = 1,
          step = 0.01,
          get = function(info) return db.bgcolorg end,
          set = function(info, bgg)
          db.bgcolorg = bgg
          Rapture:Runtestbar()
          end,
        },
        bgB = {
          order = 14,
          name = "Blue",
          desc = "Set blue color",
          type = 'range',
          min = 0,
          max = 1,
          step = 0.01,
          get = function(info) return db.bgcolorb end,
          set = function(info, bgb)
          db.bgcolorb = bgb
          Rapture:Runtestbar()
          end,
        },
        bgA = {
          order = 15,
          name = "Alpha",
          desc = "Set the alpha",
          type = 'range',
          min = 0,
          max = 1,
          step = 0.01,
          get = function(info) return db.bgcolora end,
          set = function(info, bga)
          db.bgcolora = bga  
          Rapture:Runtestbar()
          end,
        },
      },
    },
	message = {
      type = "group",
      name = "Message Frame",
      args = {
		frametime = {
          order = 1,
          name = "Up time",
          desc = "How long the frame will be shown",
          type = 'range',
          min = 1,
          max = 12,
          step = 1,
          get = function(info) return db.frametime end,
          set = function(info, x) 
          db.frametime = x
          Rapture:Runtestbar()
          end,
        },
		fadetime = {
          order = 2,
          name = "Fade time",
          desc = "How long it takes to hide the frame",
          type = 'range',
          min = 0.1,
          max = 1,
          step = 0.1,
          get = function(info) return db.fadetime end,
          set = function(info, x) 
          db.fadetime = x
          Rapture:Runtestbar()
          end,
        },
		framefont = {
          order = 3,
          type = "select",
          name = "Font",
          desc = "Set the font",
          values = rapmedia:HashTable("font"),
          dialogControl = "LSM30_Font",
          get = function(info) return db.framefont end,
          set = function(info, f) 
          db.framefont = f
          Rapture:Runtestbar()
          end,
        },
        framefontscale = {
          order = 4,
          name = "Font Scale",
          desc = "Set the font scale",
          type = 'range',
          min = 1,
          max = 24,
          step = 1,
          get = function(info) return db.framefontscale end,
          set = function(info, fontsc) 
          db.framefontscale = fontsc
          Rapture:Runtestbar()
          end,
        },
        frameoutline = {
          order = 5,
          name = "Outline",
          desc = "Outline",
          type = 'select',
          values = {["OUTLINE"]="Outline", ["THICKOUTLINE"]="Thickoutline", ["MONOCHROME"]="Monochrome", ["NONE"]="None"},
          get = function(info) return db.frameoutline end,
          set = function(info, line)
          db.frameoutline = line
          Rapture:Runtestbar()
          end,
        },
		framelabelinput = {
          order = 6,
          name = "Frame text",
          desc = "Frame text",
          type = 'input',
          get = function(info) return db.framelabelinput end,
          set = function(info, line)
          db.framelabelinput = line
          Rapture:Runtestbar()
          end,
        },
		framepos = {
          order = 7,
          type = "description",
          name = "\n\nFrame Position\n",
          cmdHidden = true
        },
		framexpos = {
          order = 9,
          name = "X",
          desc = "Change horizontal position",
          type = 'range',
          min = -500,
          max = 500,
          step = 1,
          get = function(info) return db.framexpos end,
          set = function(info, x) 
          db.framexpos = x
          Rapture:Runtestbar()
          end,
        },
        frameypos = {
          order = 12,
          name = "Y",
          desc = "Change veritcal position",
          type = 'range',
          min = -500,
          max = 500,
          step = 1,
          get = function(info) return db.frameypos end,
          set = function(info, y) 
          db.frameypos = y
          Rapture:Runtestbar()
          end,
        },
        framenudgeright = {
          order = 10,
          name = "Right",
          desc = "Nudge right once",
          type = 'execute',
          get = function(info) return db.framexpos end,
          func = function() 
          db.framexpos = db.framexpos + 1
          Rapture:Runtestbar()
          end,
        },
        framenudgeleft = {
          order = 8,
          name = "Left",
          desc = "Nudge left once",
          type = 'execute',
          get = function(info) return db.framexpos end,
          func = function() 
          db.framexpos = db.framexpos - 1
          Rapture:Runtestbar()
          end,
        },
        framenudgeup = {
          order = 11,
          name = "Up",
          desc = "Nudge up once",
          type = 'execute',
          get = function(info) return db.frameypos end,
          func = function() 
          db.frameypos = db.frameypos + 1
          Rapture:Runtestbar()
          end,
        },
        framenudgedown = {
          order = 13,
          name = "Down",
          desc = "Nudge down once",
          type = 'execute',
          get = function(info) return db.frameypos end,
          func = function() 
          db.frameypos = db.frameypos - 1
          Rapture:Runtestbar()
          end,
        },
	  },
	},
	framecolors = {
      type = "group",
      name = "Message Frame Colors",
      args = {
          framebarcolordesc = {
          order = 1,
          type = "header",
          name = "Text color\n",
          cmdHidden = true
        },
        framecolor = {
          order = 2,
          name = "Bar color",
          desc = "Set color",
          type = 'color',
          get = function(info) return db.framecolorr, db.framecolorg, db.framecolorb end,
          set = function(info, r, g, b, a)
          db.framecolorr, db.framecolorg, db.framecolorb = r, g, b
          Rapture:Runtestbar()
          end,
        },
        framecolorrgbadesc = {
          order = 3,
          type = "description",
          name = "\n\nRGB changer\n",
          cmdHidden = true
        },
        frameR = {
          order = 4,
          name = "Red",
          desc = "Set red color",
          type = 'range',
          min = 0,
          max = 1,
          step = 0.01,
          get = function(info) return db.framecolorr end,
          set = function(info, r)
          db.framecolorr = r
          Rapture:Runtestbar()
          end,
        },
        frameG = {
          order = 5,
          name = "Green",
          desc = "Set green color",
          type = 'range',
          min = 0,
          max = 1,
          step = 0.01,
          get = function(info) return db.framecolorg end,
          set = function(info, g)
          db.framecolorg = g
          Rapture:Runtestbar()
          end,
        },
        frameB = {
          order = 6,
          name = "Blue",
          desc = "Set blue color",
          type = 'range',
          min = 0,
          max = 1,
          step = 0.01,
          get = function(info) return db.framecolorb end,
          set = function(info, b)
          db.framecolorb = b
          Rapture:Runtestbar()
          end,
        },
	},
	},
	extras = {
      type = "group",
      name = "Extras",
      args = {
        sound = {
          order = 1,
          name = "Enable sound",
          desc = "Enable sound",
          type = 'toggle',
          get = function(info) return db.soundenable end,
          set = function(info, x) 
          db.soundenable = x
          Rapture:Runtestbar()
          end,
        },
		enableframe = {
          order = 3,
          name = "Enable message frame",
          desc = "Enable message frame",
          type = 'toggle',
          get = function(info) return db.frameenable end,
          set = function(info, x) 
          db.frameenable = x
          Rapture:Runtestbar()
          end,
        },
	  },
	},
  },
}
	
function Rapture:OnInitialize()
    self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Rapture", "Rapture")
    LibStub("AceConfig-3.0"):RegisterOptionsTable("Rapture", options, {"rapture", "rap", "Rapture", "Rap"})
    LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("Rapture", options)
    self.db = LibStub("AceDB-3.0"):New("RaptureDB", defaults)
	db = self.db.profile
	options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
    self:RegisterChatCommand("rap", "ChatCommand")
    self:RegisterChatCommand("Rapture", "ChatCommand")
	self.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig")
	self.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig")
	self.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig")
	
	local function barstopped( callback, bar )
		local candylabel = bar.candyBarLabel:GetText()
		if candylabel == db.labelinput then
			if db.soundenable == true then
				PlaySoundFile("interface\\addons\\ingelasrapture\\media\\ready.ogg")
			end
			if RaptureBAR and RaptureBAR == bar then
				RaptureBAR = nil
			end
			Rapture:frame()
		end
	end
	
	rapcandy.RegisterCallback(self, "LibCandyBar_Stop", barstopped)
	RaptureTEST = rapcandy:New(rapmedia:Fetch("statusbar", db.texture), db.width, db.height)
end
	
function Rapture:OnEnable()
    self:Print("Rapture Loaded")
    self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    if not rapmedia:Fetch("statusbar", db.texture, true) then db.texture = "Blizzard" end
    if not rapmedia:Fetch("font", db.font, true) then db.font = "Friz Quadrata TT" end
end

function Rapture:RefreshConfig()
	db = self.db.profile
end

function Rapture:frame()
	rapframe = CreateFrame("MessageFrame","Rapframe",UIParent)
	rapframe:SetWidth(300)
	rapframe:SetHeight(25)
	rapframe:SetTimeVisible(db.frametime)
	rapframe:SetFadeDuration(db.fadetime)
	rapframe:SetFont(rapmedia:Fetch("font", db.framefont), db.framefontscale, db.frameoutline~="NONE" and db.frameoutline or nil)
	rapframe:SetPoint("CENTER", UIParent, "CENTER", db.framexpos, db.frameypos)
	rapframe:AddMessage(db.framelabelinput, db.framecolorr, db.framecolorg, db.framecolorb)
	rapframe:Show()
	if db.frameenable == false then
		rapframe:Hide()
	end
end

function Rapture:Runbar()
	if rapframe then
		rapframe:SetTimeVisible(0.1)
	end
    if not RaptureBAR then
        RaptureBAR = rapcandy:New(rapmedia:Fetch("statusbar", db.texture), db.width, db.height)
        RaptureBAR:Set("none", none)
        RaptureBAR:SetTexture(rapmedia:Fetch("statusbar", db.texture))
        RaptureBAR:SetWidth(db.width)
        RaptureBAR:SetHeight(db.height)
        RaptureBAR:SetScale(db.scale)
        RaptureBAR:SetPoint("CENTER", UIParent, "CENTER", db.xpos, db.ypos)
        RaptureBAR:SetColor(db.colorr, db.colorg, db.colorb, db.colora)
        RaptureBAR.candyBarLabel:SetFont(rapmedia:Fetch("font", db.font), db.fontscale, db.outline~="NONE" and db.outline or nil)
        RaptureBAR.candyBarDuration:SetFont(rapmedia:Fetch("font", db.font), db.fontscale, db.outline~="NONE" and db.outline or nil)
        RaptureBAR.candyBarBackground:SetVertexColor(db.bgcolorr, db.bgcolorg, db.bgcolorb, db.bgcolora)
        RaptureBAR.candyBarLabel:SetJustifyH(db.alignment)
        RaptureBAR:SetLabel(db.labelinput)
    end
    RaptureBAR:SetDuration(12)
    RaptureBAR:Start()
end

function Rapture:Runtestbar()
	if rapframe then
		rapframe:SetTimeVisible(0.1)
	end
    RaptureTEST:Set("none", none)
    RaptureTEST:SetTexture(rapmedia:Fetch("statusbar", db.texture))
    RaptureTEST:SetWidth(db.width)
    RaptureTEST:SetHeight(db.height)
    RaptureTEST:SetScale(db.scale)
    RaptureTEST:SetPoint("CENTER", UIParent, "CENTER", db.xpos, db.ypos)
    RaptureTEST:SetColor(db.colorr, db.colorg, db.colorb, db.colora)
    RaptureTEST.candyBarLabel:SetFont(rapmedia:Fetch("font", db.font), db.fontscale, db.outline~="NONE" and db.outline or nil)
    RaptureTEST.candyBarDuration:SetFont(rapmedia:Fetch("font", db.font), db.fontscale, db.outline~="NONE" and db.outline or nil)
    RaptureTEST.candyBarBackground:SetVertexColor(db.bgcolorr, db.bgcolorg, db.bgcolorb, db.bgcolora)
    RaptureTEST.candyBarLabel:SetJustifyH(db.alignment)
    RaptureTEST:SetLabel(db.labelinput)
	RaptureTEST:SetDuration(2)
	RaptureTEST:Start()
	if RaptureBAR then
	RaptureBAR:Stop()
	end
end

function Rapture:SPELL_ENERGIZE(timestamp, event, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, spellId, spellName, spellSchool, auraType, amount)
    local player_name = UnitName("player")
    if destName == player_name and sourceName == player_name and spellId == 47755 then
        Rapture:Runbar()
    end
end

function Rapture:COMBAT_LOG_EVENT_UNFILTERED(_, timestamp, event, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, amount, spellID, ...)
    local func = self[event]
    if (func) then
        func(self, timestamp, event, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, amount, spellID, ...)
    end
end

function Rapture:ChatCommand(input)
    if not input or input:trim() == "" then
        InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
    else
        LibStub("AceConfigCmd-3.0").HandleCommand(Rapture, "rap", "Rapture", input)
    end
end

Last edited by Julchen : 04-01-11 at 12:58 PM.
Julchen is offline   Reply With Quote
Unread 04-01-11, 12:52 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 9,554
That's all standard Lua - there is no reference to the Ace libraries or their methods. Your problem is what I pointed out in my final edit.

First you do this:
local timestamp, type, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, -- arg1 to arg8
spellId, spellName, spellSchool, -- arg9 to arg11
amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing = ... -- arg12 to arg20
then you are doing this:
local spellId, spellName, spellSchool, amount, powerType = ...
the ... is the same stuff that it was before, so your second spellId variable holds the same info as your timestamp variable and so on.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

Seerah is offline   Reply With Quote
Unread 04-01-11, 02:03 PM   #5
Julchen
A Deviate Faerie Dragon
Join Date: Dec 2009
Posts: 17
Okay that does the ... thanks. I changed it so this should fixed.
Code:
function Foo_OnEvent(self, event, ...)

local timestamp, event, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, spellId, spellName, spellSchool, auraType, amount

  if (event == "COMBAT_LOG_EVENT_UNFILTERED") then
    if (type == "SPELL_ENERGIZE") then
		local player_name = UnitName("player")
		
		if destName == player_name and sourceName == player_name and spellId == 47755 then
		
		print("TESTESTESTESTEST")
	  
		end
    end
  end
end

local f = CreateFrame("Frame", "Foo_Frame")
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
f:SetScript("OnEvent", Foo_OnEvent)
but didnt work either :/
Julchen is offline   Reply With Quote
Unread 04-01-11, 02:07 PM   #6
Duugu
Premium Member
 
Duugu's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 588
There's no variable type - which means you can't do
Code:
if (type == "SPELL_ENERGIZE") then
Duugu is offline   Reply With Quote
Unread 04-01-11, 02:34 PM   #7
Julchen
A Deviate Faerie Dragon
Join Date: Dec 2009
Posts: 17
Hmm in the example on http://www.wowpedia.org/API_COMBAT_LOG_EVENT they just changed event to type. I did it also but i really dont unterstand why it doesnt work. Remove some arg i didnt need.
Code:
function Foo_OnEvent(self, event, ...)
	local _, type, _, sourceName, _, _, destName, _, spellId

    if (type == "SPELL_ENERGIZE") then
		local player_name = UnitName("player")		
		if destName == player_name and sourceName == player_name and spellId == 47537 then --47755 then
		
		print("TESTESTESTESTEST")
	  
		end
    --end
  end
end

local f = CreateFrame("Frame", "Foo_Frame")
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
f:SetScript("OnEvent", Foo_OnEvent)
Julchen is offline   Reply With Quote
Unread 04-01-11, 03:02 PM   #8
Duugu
Premium Member
 
Duugu's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 588
Within your last sample code type is nil because you do not assign something.
Duugu is offline   Reply With Quote
Unread 04-01-11, 03:51 PM   #9
Julchen
A Deviate Faerie Dragon
Join Date: Dec 2009
Posts: 17
Originally Posted by Duugu View Post
Within your last sample code type is nil because you do not assign something.
Thanks to all for the hints/tips - you helped me alot to understand the function syntax better and solve my problem!
Julchen is offline   Reply With Quote
Unread 04-01-11, 05:54 PM   #10
Julchen
A Deviate Faerie Dragon
Join Date: Dec 2009
Posts: 17
Double post _ next questen :/

Now I want to Create a Cooldown Frame. But i cant find anything how to say the Cooldown Frame that it Count down a spezific Time. Also they Counter should count down. I didnt find any easy example - tried some code from sfilter but no success.

Code:
function Foo_OnEvent(self, event, ...)
	local _, type, _, sourceName, _, _, destName, _, spellId = ... 

    if (type == "SPELL_ENERGIZE") then
		local player_name = UnitName("player")	

		if destName == player_name and sourceName == player_name and spellId == 47755 then
		
		print("Rapture Proc - 12s Cooldown")
			local f = CreateFrame("Frame",nil,UIParent)
			f:SetWidth(39)
			f:SetHeight(39)
			f:SetPoint("CENTER", UIParent, "CENTER", 0.5, 0.5)
	
			f.icon = f:CreateTexture("$parentIcon", "BACKGROUND")
			f.icon:SetAllPoints(f)
			f.icon:SetTexture(GetSpellTexture(47755))
			f.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)

			f.cooldown = CreateFrame("Cooldown", nil, f, "CooldownFrameTemplate")
			f.cooldown:SetPoint("TOPLEFT")
			f.cooldown:SetPoint("BOTTOMRIGHT")
			f.cooldown:SetReverse()

			f.count = FreeUI.CreateFS(f, 8)
			f.count:SetTextColor(.9, .9, .9)
			f.count:SetPoint("TOP")
	  
			local bg = CreateFrame ("Frame", nil, f)
			bg:SetBackdrop({ 
			bgFile = FreeUI.backdrop, 
			})
			bg:SetBackdropColor(0, 0, 0)
			bg:SetPoint("TOPLEFT", f, -1, 1)
			bg:SetPoint("BOTTOMRIGHT", f, 1, -1)
			bg:SetFrameStrata("LOW")
		end
	end
end
I cant find a way to show up the Frame for 12 seconds with cooldown timer and counter
Julchen is offline   Reply With Quote
Unread 04-01-11, 05:58 PM   #11
Duugu
Premium Member
 
Duugu's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 588
Originally Posted by Julchen View Post
Now I want to Create a Cooldown Frame.
A bar? Or someting like an action button timer?
Duugu is offline   Reply With Quote
Unread 04-01-11, 06:08 PM   #12
Julchen
A Deviate Faerie Dragon
Join Date: Dec 2009
Posts: 17
hmm need onupdate because their is no event triggered if rapture is ready - damn but problem solved so far thanks for all the help

Last edited by Julchen : 04-02-11 at 03:55 PM.
Julchen is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Lua/XML Help » Rapture Tracking Problem

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off