Thread Tools Display Modes
06-04-09, 11:23 PM   #21
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
There aren't any restrictions on the name of the function. This code actually should be top-level though, or else you need to call "Frame1_OnEvent()" (a misnomer because Frame1's OnEvent handler is actually the function you're passing to SetScript).

Also, it's very possible that "Frame1" is in conflict with something else, unless that is a local reference that you created earlier. If it's a name that you passed to CreateFrame() then it will always be global, so if you create named frames it's best to give them names that are unique.

Last edited by Akryn : 06-04-09 at 11:26 PM.
  Reply With Quote
06-05-09, 04:27 PM   #22
goris29
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jun 2009
Posts: 16
Okay, I got the addon to pop up on all the member's screen. Now how would I go about setting people's name and answer to a frame? By that I mean what method would I use to do that, I'm just simply going to use three different methods with a different answer added to each button. How would I then take that answer then put it on a frame as a fontstring?

Sorry, that may seem a little wordy, but I didn't know how to put the question.
  Reply With Quote
06-05-09, 05:03 PM   #23
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
This is easier to just write out than to explain. There are lots of other ways that you could do this as well, this is probably the simplest.
If MyFrame is the frame that you want the text to display in, then...

Code:
MyFrame.OnShow(self, ...)
   if self.MyFontStrings  then
      wipe(MyFontStrings)
   end

   self.MyFontStrings = {}
end
-------------------
MyFrame.EventHandler(self, event, ...)
    if event == "CHAT_MSG_ADDON" then
       local prefix, msg, type, sender = ...

       if prefix ~= "MyAddon_Reply" then return end

       local fontString = self:CreateFontString(nil,"OVERLAY")
       local anchorTo = (#self.MyFontStrings > 0) and self.MyFontStrings[#self.MyFontStrings] or self -- anchor to the last fontstring or to the parent frame if none
       self.MyFontStrings[#self.MyFontStrings + 1] = fontString
       fontString:ClearAllPoints()
       fontString:SetPoint("TOPLEFT", anchorTo, "TOPLEFT", 0, -5)
   
       fontString:SetText(("%s replied with %s."):Format(sender, msg))
    end
end
  Reply With Quote
06-05-09, 06:42 PM   #24
goris29
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jun 2009
Posts: 16
I'm getting an error saying <unnamed>:SetTExt(); Font not set. Any suggestions?

Last edited by goris29 : 06-05-09 at 08:00 PM.
  Reply With Quote
06-05-09, 08:01 PM   #25
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by goris29 View Post
Should there be a "function" in front of MyFrame.EventHandler and MyFrame.OnShow?...And i also get errors about trying to index global values w/ a value of nil.
Yes they should be declared as functions, sorry. Actually there are other problems with it as well, which I didn't notice before because I wasn't really paying attention x_x The global variables thing is not one of those problems though; if there are variables referenced in my code that you aren't creating, then you need to change the names in my code to match yours, or change the code to apply to the way you're doing things.

Also, as I noted above, the major problem with what I posted before is that the table of fontstrings should *not* be cleared the second+ times the frame is shown, they should just all have :hide() called on them. The event handler should check to see if the table exists, and if so search backwards from the end for the last fontstring that :IsHidden(), and use that if there is one. If there is no fontstring in the table or if the last one is visible, then create a new one and append it to the end.
  Reply With Quote
06-05-09, 08:04 PM   #26
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
I'm getting an error saying <unnamed>:SetTExt(); Font not set. Any suggestions?
Oh right the API changed...add a fontString:SetFont("GameFontNormal") in there before the :SetText() line.
  Reply With Quote
06-05-09, 08:12 PM   #27
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
You might actually also be able to just make a single fontstring, set it really tall, and then append "\n....whatever" to the end of it as each reply comes in. That would be a lot easier. I don't know if that would work because TBH I just use scrollframes whenever I want to display a lot of data.
  Reply With Quote
06-05-09, 08:20 PM   #28
goris29
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jun 2009
Posts: 16
Now I'm getting a usage error. Usage:<unnamed>:SetFont("font",fontHeight[,flags})
  Reply With Quote
06-05-09, 08:32 PM   #29
goris29
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jun 2009
Posts: 16
Now I'm getting another error. attempt to call method 'Format' (a nil value). Does this mean that I have to write Format?
  Reply With Quote
06-05-09, 08:35 PM   #30
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by goris29 View Post
Now I'm getting a usage error. Usage:<unnamed>:SetFont("font",fontHeight[,flags})
Stupid fontstring changes, I actually launched wow and tried it out this time...

:SetFont(GameFontNormal:GetFont(), 9)
  Reply With Quote
06-05-09, 08:41 PM   #31
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by goris29 View Post
Now I'm getting another error. attempt to call method 'Format' (a nil value). Does this mean that I have to write Format?
No it should be :format() sorry.
  Reply With Quote
06-05-09, 09:12 PM   #32
goris29
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jun 2009
Posts: 16
Well thanks man. I finally got the whole thing working. I really appreciate all of the help you gave me. It really means a lot to me.
  Reply With Quote
06-05-09, 09:24 PM   #33
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by goris29 View Post
Well thanks man. I finally got the whole thing working. I really appreciate all of the help you gave me. It really means a lot to me.

.......10char
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Raid Leader Button

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