View Single Post
12-28-10, 08:47 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,330
Originally Posted by stormszero View Post
Now, as far as I can understand PLAYER_TARGET_CHANGED fires whenever you click a character, npc or it deselects for any reason. However, when I click an NPC in orgrimmar, it just prints "nil" to the default chat frame (which happens because the content of "event" is nil); If I attempt to output "event" (i.e. print(event)) or output the various argX variables, they're all nils.

Again, I am new to LUA but I do understand the concepts from other languages, but this is a completely new syntax for me, I'm used to C-style languages, so forgive me if I am literally standing on the answer

/Klaus
Originally Posted by stormszero View Post
First, the XML file:
Code:
<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="HMana.lua"/>
	<Frame name="hManaFrame" toplevel="true" parent="UIParent" frameStrata="DIALOG" hidden="false" enableMouse="true" movable="true">
...
		<Scripts>
			<OnLoad>
				hMana_OnLoad();
			</OnLoad>
			<OnEvent>
				hMana_OnEvent();
			</OnEvent>
...
Right now, your XML file isn't passing any of the parameters for the event handlers. Using the old style is tricky since it wraps the handler with a function that has prenamed parameters. You can bypass this by using the function="func" attribute for the script tag.

Here's an example.
Code:
<OnLoad function="hMana_OnLoad"/>
<OnEvent function="hMana_OnEvent"/>
Note this is not a function call, it's simply grabbing the pointer to the function and setting the script handler to it. The function MUST EXIST at the time you make this assignment otherwise the handler will never run (the function referenced will be nil).
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote