11/8/2008 This was removed with 3.02. Use UNIT_AURA instead.
After looking through some event's, that seem's like it might be the correct one.
Test it, add it to your AddOn, make sure you have the coding correct, and cause the event to fire, if whatever you want to happen, occur's then it's the right event.
It says that event was removed two years ago, so probably not. :P The character stats frame seems to use these events (among others):
"COMBAT_RATING_UPDATE"
"PLAYER_EQUIPMENT_CHANGED"
"UNIT_STATS" (arg1 == "player")
Seem's "UNIT_STATS" would be what he is looking for since agility effect's crit chance, and possibly call PLAYER_EQUIPMENT_CHANGED beforehand.
But with "UNIT_STATS" if an item is equipped with crit chance as a stat, UNIT_STATS" won't recognize it, since it is for main stat's -- Stamina, Agility, etc..
this is what i did
if it is wrong let me know because the text does not show up
local critChance
function eventHandler(self, event, ...)
critChance = GetCritChance()
critChance = format("%.2f", critChance)
end
if i take critChane out of the function i see numbers
local myframe = CreateFrame("Frame", nil, UIParent)
myframe:SetWidth(150)
myframe:SetHeight(50)
myframe:RegisterEvent("UNIT_STATS")
myframe:SetScript("OnEvent", eventHandler)
myframe:Show()
myframe:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
myframe:SetMovable(true)
myframe:EnableMouse(true)
myframe:SetScript("OnMouseDown", function(self, button)
if button == "LeftButton" and not self.isMoving then
self:StartMoving();
self.isMoving = true;
end
end)
myframe:SetScript("OnMouseUp", function(self, button)
if button == "LeftButton" and self.isMoving then
self:StopMovingOrSizing();
self.isMoving = false;
end
end)
myframe:SetBackdrop(GameTooltip:GetBackdrop())
A tip: when posting code, but the [code ] [/code ] brackets around it, or use paste.wowace.com or pastey.net it will make it much easier to read and debug.
Well, you're still expecting it to happen automatically. The text will only change when you call SetText. The button isn't aware of that a variable was used to set its text. The following are exactly identical:
local a = 1
btn:SetText(a)
btn:SetText(1)
You're just assigning a new value to the variables, but that changes nothing. You need to SetText when you want the text to update.
Seem's "UNIT_STATS" would be what he is looking for since agility effect's crit chance, and possibly call PLAYER_EQUIPMENT_CHANGED beforehand.
But with "UNIT_STATS" if an item is equipped with crit chance as a stat, UNIT_STATS" won't recognize it, since it is for main stat's -- Stamina, Agility, etc..
Yes, you would use them all. COMBAT_RATING_UPDATE would fire for crit rating.
The first option you posted is correct, this one is wrong. Functions are first-order types, you can just pass then as variables. The moment you add parenthesis, it is assumed to be a function call no longer an access to the variable. Check the lua reference manual to get a more detailed explanation on this.
The first option you posted is correct, this one is wrong. Functions are first-order types, you can just pass then as variables. The moment you add parenthesis, it is assumed to be a function call no longer an access to the variable. Check the lua reference manual to get a more detailed explanation on this.
I'm going to have to do this sometime soon, i want to totally cut xml from my AddOn's, even though it's KINDA easy to use.
i am wondring i have something wrong with my onevent
nothing shows up when it loads or changes stats http://paste.wowace.com/3053/
will change it when i come up with something
local function eventHandler(self, event, ...)
local critChance = GetCritChance()
local critChance = format("%.2f", critChance)
crtm:SetText(critChance)
end
As i stated before, don't use local function, it's not needed.
Also, i don't know about frame's in lua, but in xml you need to tell the frame to have a text, before you can set the text to something.
So you would just set the text to "" and it would work great. You might need to do something like this in lua.
Assuming your code is all you want this to do, then don't use Ace3; which you aren't even using right now, actually. At least not properly. Line 3 should not be local, and the variable critChance is only visible to that function because you defined it as local to that function.
That's at first glance.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
After looking through some event's, that seem's like it might be the correct one.
Test it, add it to your AddOn, make sure you have the coding correct, and cause the event to fire, if whatever you want to happen, occur's then it's the right event.
"COMBAT_RATING_UPDATE"
"PLAYER_EQUIPMENT_CHANGED"
"UNIT_STATS" (arg1 == "player")
Seem's "UNIT_STATS" would be what he is looking for since agility effect's crit chance, and possibly call PLAYER_EQUIPMENT_CHANGED beforehand.
But with "UNIT_STATS" if an item is equipped with crit chance as a stat, UNIT_STATS" won't recognize it, since it is for main stat's -- Stamina, Agility, etc..
local function eventHandler(self, event, ...)
local critChance = GetCritChance()
local critChance = format("%.2f", critChance)
end
now from my label my chritChance Does not there
local myframe = CreateFrame("Frame", nil, UIParent)
myframe:SetWidth(150)
myframe:SetHeight(50)
myframe:RegisterEvent("UNIT_STATS")
myframe:SetScript("OnEvent", eventHandler)
myframe:Show()
crtm:SetPoint("CENTER", myframe, "CENTER", 30, 0)
crtm:SetText(critChance)
crtm:SetFont("Fonts\\FRIZQT__.TTF", 30)
I don't use LUA for creating frame's so my little knowledge is much less here.
But why are you localizing the function?
This was given to me for help also by Phanx:
So to add a function to this frame, I'm assuming you would just do:
f:SetScript("OnEvent", function(self)
self:functionName(args)
end)
And just do:
I think...
You might want to wait for a more educated answer before relying on my answer.
if it is wrong let me know because the text does not show up
local critChance
function eventHandler(self, event, ...)
critChance = GetCritChance()
critChance = format("%.2f", critChance)
end
if i take critChane out of the function i see numbers
local myframe = CreateFrame("Frame", nil, UIParent)
myframe:SetWidth(150)
myframe:SetHeight(50)
myframe:RegisterEvent("UNIT_STATS")
myframe:SetScript("OnEvent", eventHandler)
myframe:Show()
myframe:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
myframe:SetMovable(true)
myframe:EnableMouse(true)
myframe:SetScript("OnMouseDown", function(self, button)
if button == "LeftButton" and not self.isMoving then
self:StartMoving();
self.isMoving = true;
end
end)
myframe:SetScript("OnMouseUp", function(self, button)
if button == "LeftButton" and self.isMoving then
self:StopMovingOrSizing();
self.isMoving = false;
end
end)
myframe:SetBackdrop(GameTooltip:GetBackdrop())
local crtlbl = myframe:CreateFontString(nil, "ARTWORK", "GameFontNormal")
crtlbl:SetPoint("CENTER", myframe, "CENTER", -30, 0)
crtlbl:SetText("crit%: ")
crtlbl:SetFont("Fonts\\FRIZQT__.TTF", 30)
local crtm = myframe:CreateFontString(nil, "ARTWORK", "GameFontNormal")
crtm:SetPoint("CENTER", myframe, "CENTER", 30, 0)
crtm:SetText(critChance)
And was my example correct?
You also noticed that quoting code doesn't work because it puts smilies into the lines. :D
You're just assigning a new value to the variables, but that changes nothing. You need to SetText when you want the text to update.
Yes, you would use them all. COMBAT_RATING_UPDATE would fire for crit rating.
Define critChance in you local variable
And you are just changing critChance with:
(I think. I don't really know about the format function, but it might not)
And this might be wrong:
Maybe try this:
But like i said, i basically know nothing about frame's with lua.
The first option you posted is correct, this one is wrong. Functions are first-order types, you can just pass then as variables. The moment you add parenthesis, it is assumed to be a function call no longer an access to the variable. Check the lua reference manual to get a more detailed explanation on this.
I'm going to have to do this sometime soon, i want to totally cut xml from my AddOn's, even though it's KINDA easy to use.
nothing shows up when it loads or changes stats
http://paste.wowace.com/3053/
will change it when i come up with something
As i stated before, don't use local function, it's not needed.
Also, i don't know about frame's in lua, but in xml you need to tell the frame to have a text, before you can set the text to something.
So you would just set the text to "" and it would work great. You might need to do something like this in lua.
Where are you telling it to register the event?
That's at first glance.