Recent Additions to 'New to mod programming, GameTooltip API question'http://wowprogramming.com/forums/development/95.rss
http://wowprogramming.com/forums/development/95/4
forums/development/95/4Fri, 24 Apr 2009 04:03:54 +0000jnwhiteh<blockquote>
<p>Instantiate a local boolean variable. Since the scope is local whenever the UI gets reset (i.e. on logout) the variable loses its value.</p>
</blockquote>
<p>Not entirely. &nbsp;The local scope just means that it cannot be accessed by anything outside that scope. &nbsp;The scope of a variable really has no bearing on whether or not it is saved. &nbsp;Read the section of the book on SavedVariables for more information.</p>
<blockquote>
<p>Create a user-defined function where if boolean is false, add the line of text and make boolean true, otherwise do nothing. Make another user defined function where the boolean is reset whenever a call is made to the WoW built-in event OnTooltipCleared. Map the two local, user-defined functions to their WoW built-in event counterparts of the same name.</p>
<p>Does this mean that no call to registerEvent is necessary? Or do I still need to register the OnTooltipSetItem and OnTooltipCleared events?</p>
</blockquote>
<p>They are not events, they are script handlers. &nbsp;You should read the chapter on adding behavior to frames to better understand the difference.</p>
<blockquote>
<p><br />Sorry for so many questions but I am used to several other languages where small things like these can make a huge difference in whether or not the program works.</p>
<p>Also, does WoWProgramming have a link to the snippets section? I couldn't find that link anywhere aside from the hyperlink in the last post.</p>
</blockquote>
<p>Its on the main page of the site, yes. &nbsp;You can access it directly at http://wowprogramming.com/misc/snippets.</p>http://wowprogramming.com/forums/development/95/3
forums/development/95/3Thu, 23 Apr 2009 17:27:06 +0000pocnib<p>Thank you so much for your prompt response. Just to make sure that I understand what the snippet you linked to does exactly...</p>
<p>Instantiate a local boolean variable. Since the scope is local whenever the UI gets reset (i.e. on logout) the variable loses its value. Create a user-defined function where if boolean is false, add the line of text and make boolean true, otherwise do nothing. Make another user defined function where the boolean is reset whenever a call is made to the WoW built-in event OnTooltipCleared. Map the two local, user-defined functions to their WoW built-in event counterparts of the same name.</p>
<p>Does this mean that no call to registerEvent is necessary? Or do I still need to register the OnTooltipSetItem and OnTooltipCleared events?</p>
<p><br />Sorry for so many questions but I am used to several other languages where small things like these can make a huge difference in whether or not the program works.</p>
<p>Also, does WoWProgramming have a link to the snippets section? I couldn't find that link anywhere aside from the hyperlink in the last post.</p>http://wowprogramming.com/forums/development/95/2
forums/development/95/2Thu, 23 Apr 2009 16:48:14 +0000jnwhiteh<p>Its actually a bit weird.&nbsp; Here's a snippet that adds a line to all item tooltips: <a href="http://wowprogramming.com/misc/snippets/add_lines_to_item_tooltip">http://wowprogramming.com/misc/snippets/add_lines_to_item_tooltip</a>.&nbsp;</p>
<p>There is a script handler for the tooltip being set to display different types of things (items, quests, etc).&nbsp; You securely hook the OnTooltipSetItem function to catch a new item being displayed.&nbsp; But this handler can fire multiple times for certain types of items, so to ensure we only add the line once we clear a boolean flag OnTooltipCleared.</p>
<p>That's what it takes to add a line to the tooltip.</p>http://wowprogramming.com/forums/development/95/1
forums/development/95/1Thu, 23 Apr 2009 15:29:54 +0000pocnib<p>I just started playing WoW and as a computer science major and programmer by trade, the idea of writing mods was very intriguing. I am not going for anything advanced or even desireable right now, I just am trying to get the feel. I have experience with many other languages, OOP and scripting, but not Lua. I am currently reading up on Lua and making non-WoW programs, but I am interested in starting some WoW programming. I have done the basic Hello World tutorial, playing around with changing different parts of the code, but what I want to achieve next involves, I'm assuming, the GameTooltip: API. What I would like to achieve is to change the text for an item tooltip, when the user hovers over an item. For learning sake I am only trying to get it to add a set line of text to any item tooltip. A pseudo-code example</p>
<p>when mouseOverItem(item)<br />&nbsp;&nbsp;&nbsp; text = item.getTooltipText() + "THIS LINE IS ADDED TO YOUR TOOLTIP"<br />&nbsp;&nbsp;&nbsp; item.setTooltip(text)<br />&nbsp;&nbsp;&nbsp; item.showTooltip()</p>
<p>I am just wondering for WoW what events would trigger this in order to run the Lua script and what built in functions can achieve my desired result? I see functions such as GameTooltip:addLine(text), do these functions affect item tool tips? Or are they implemented only for user-defined frames from your xml or lua files? I mainly want this to work with items in bags, to make it easy for me to see it working for debugging purposes. Thank you for your time.</p>
<p><br />pocnib</p>