Monday, April 16, 2012

Displaying a notification message issue.

Hi guys.

I am an amateur programmer who has decided to learn WoW UI programming. As such, I've encountered my first hurdle and wanted to see if one of you experts could point out the problem, given:

XML:
Code:
<Ui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.blizzard.com/wow/ui/">
<Script file="WowAddon1.lua" />
<Frame name="PBFrame" parent="UIParent" toplevel="true">
<Scripts>
<OnLoad>
myLoad();
</OnLoad>
<OnEvent>
myEvent();
</OnEvent>
</Scripts>
<Frames>
<MessageFrame name="MyMessageFrame_Event" parent="UIParent" toplevel="true" frameStrata="HIGH" insertMode="TOP">
<Size>
<AbsDimension x="600" y="50" />
</Size>
<Anchors>
<Anchor point="TOP">
<Offset>
<AbsDimension x="0" y="-100" />
</Offset>
</Anchor>
</Anchors>
</MessageFrame>
</Frames>
</Frame>
</Ui>

LUA:
Code:
-- Author      : Korax
-- Create Date : 8/14/2008 7:08:20 PM

-- OnLoad Function
function myLoad()
this:RegisterEvent("COMBAT_LOG_EVENT");
end

-- OnEvent Function
function myEvent()
if (event=="COMBAT_LOG_EVENT") then
Spelltext=arg1;
if (Spelltext=="Koraxen gains Fel Armor.") then
MyMsg_Event(Spelltext);
end
end
end

-- Defining Message Function
function MyMsg_Event(msg)
MyMessageFrame_Event:AddMessage(msg,1,1,1,1,10);
end

This code is meant to detect a particular self-buff message ("Koraxen gains Fel Armor.") in the Combat Log, and display it as a more visible MessageFrame notification. Right now, it does nothing. I realize this can have little practical use, but it's simply a basic building block towards a bigger mod, as I learn the language. Could you guys please have a look and spot why it doesn't work?

Thanks!

- Koraxen|||this site might help you http://www.wowwiki.com/API_UnitBuff|||Thanks for the pointer. I don't think UnitBuff is the function call I'm looking for though.

My code is supposed to catch an event, and if that event is a particular buff message in the Combat Log, print it out in a large MessageFrame.|||UnitBuff is actually the easier way to do this rather than using combat log events.

No comments:

Post a Comment