Thread Tools Display Modes
06-25-11, 06:45 AM   #1
Tadedra
A Cliff Giant
Join Date: Dec 2010
Posts: 70
Red flag for "you feel normal"

I couldn't quite figure out how to do this with power aura but I'm trying to find something that will visually alert me to when my toon is out of rested points. I think I remember something that would aura flash the edge of the screen for different things and I'm almost sure "feeling normal" was one of those things but I haven't needed something like that in a while and can't even remember if the addon really did that or not. Any suggestions or guidance would be great.

  Reply With Quote
06-25-11, 11:46 AM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
This is simple to make...

In your WoW/Interface/AddOns folder create a folder named NoRested. Inside that folder, create a file named NoRested.toc and one named NoRested.lua


NoRested.toc
Code:
##Interface: 40100
##Name: NoRested
##Notes: Alerts you when you run out of the rested experience bonus.

NoRested.lua

NoRested.lua
Code:
local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_XP_UPDATE")
f:SetScript("OnEvent", function()
     if GetXPExhaustion() <= 0 then
          UIErrorsFrame:AddMessage("You are out of rested experience!")
     end
end)
The above is untested, but should work all the same. Let me know if it doesn't for some reason.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh


Last edited by Seerah : 06-25-11 at 03:05 PM.
  Reply With Quote
06-25-11, 01:14 PM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,336
The code is currently checking if you have rested exp and will trigger if you use any of it while some remain. The code needs to check when rested exp hits 0. Also, there's a design flaw, if you continue killing mobs after running out, it'll keep posting to the error frame. Under certain situations, like a party AoEing mobs down in an instance, will spam it.

Here's a proposed fix for these issues.
lua Code:
  1. local lastrest=1;-- Any value greater than 0
  2. local frame = CreateFrame("Frame");--       Our frame
  3. frame:RegisterEvent("PLAYER_XP_UPDATE");--  Our event
  4. frame:SetScript("OnEvent",function()--      Our handler
  5.     local rest=GetXPExhaustion();
  6.     if rest<=0 and lastrest>0 then
  7.         UIErrorsFrame:AddMessage("You are out of rested experience!");
  8.     end
  9.     lastrest=rest;
  10. end);
__________________
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)

Last edited by SDPhantom : 06-25-11 at 01:16 PM.
  Reply With Quote
06-25-11, 03:02 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Oopsie! I was thinking in my head "if the return of this function is over 0, you have rested" and I forgot to flip it for the code above. I fixed it up there now.

/edit: yeah, SDPhantom's will only give you the message once. It all depends on how you want the addon to alert you and how often.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-26-11, 02:17 AM   #5
Tadedra
A Cliff Giant
Join Date: Dec 2010
Posts: 70
I was actually thinking as a raid warning that stays there until I go to an inn. Is that possible?

Thanks for the quick coding. Plus with it coming up as a UIerror I use BaudError, will that show up in the chat or splash on the screen or should I change that Output (the only coding I've ever done is html on front page for easy web pages so please don't laugh )
  Reply With Quote
06-26-11, 12:57 PM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Because you use BaudError, and because the normal error frame fades messages after a few seconds, we'll make our own frame for the text.

Code:
local f = CreateFrame("Frame")
f:SetSize(100,15)
f:SetPoint("TOP",0,-200)
f:Hide()
local fs = f:CreateFontString(nil,nil,"GameFontNormalLarge")
fs:SetJustifyH("CENTER")
fs:SetText("You are out of rested experience!")

f:RegisterEvent("PLAYER_XP_UPDATE")
f:RegisterEvent("PLAYER_UPDATE_RESTING")
f:SetScript("OnEvent", function(self,event)
     if event == "PLAYER_XP_UPDATE" then
          if GetXPExhaustion() <= 0 then
               f:Show()
          end
     else
          if IsResting() then
               f:Hide()
          elseif GetXPExhaustion() <=0 then
               f:Show()
          end
     end
end)
This will not show the message when logging in. If you have no rested when logging in and wish the addon to check for it, then we'll need to add that. Right now, we'll assume that you were good and logged out in an inn/city.


/edit: if all seems to be working, I can upload it here for others, too.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-27-11, 10:31 AM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
To fix the nil errors (wowprogramming did not say that GetXPExhaustion() could return nil) then make these changes (the 2 bold lines):
Code:
local f = CreateFrame("Frame")
f:SetSize(100,15)
f:SetPoint("TOP",0,-200)
f:Hide()
local fs = f:CreateFontString(nil,nil,"GameFontNormalLarge")
fs:SetJustifyH("CENTER")
fs:SetText("You are out of rested experience!")

f:RegisterEvent("PLAYER_XP_UPDATE")
f:RegisterEvent("PLAYER_UPDATE_RESTING")
f:SetScript("OnEvent", function(self,event)
     if event == "PLAYER_XP_UPDATE" then
          if GetXPExhaustion() then
               f:Show()
          end
     else
          if IsResting() then
               f:Hide()
          elseif GetXPExhaustion() then
               f:Show()
          end
     end
end)
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-28-11, 03:21 AM   #8
Tadedra
A Cliff Giant
Join Date: Dec 2010
Posts: 70
Well I gave it a whirl b4 the servers went down and I wasn't getting an error but nothing was coming up either. I will check a bit more closely during my patch day addon fun fest.

Thanks again for the help
  Reply With Quote
06-29-11, 02:55 PM   #9
Tadedra
A Cliff Giant
Join Date: Dec 2010
Posts: 70
hi,

Finally got 90% of my addons working. I'm glad I like doing this stuff.

Well I tried a toon with only toomanyaddons and norested addons on. I didn't get any frame popup or error at all but in the chat box I only got the "you feel normal" statement.

The lua file is:

local f = CreateFrame("Frame")
f:SetSize(100,15)
f:SetPoint("TOP",0,-200)
f:Hide()
local fs = f:CreateFontString(nil,nil,"GameFontNormalLarge")
fs:SetJustifyH("CENTER")
fs:SetText("You are out of rested experience!")

f:RegisterEvent("PLAYER_XP_UPDATE")
f:RegisterEvent("PLAYER_UPDATE_RESTING")
f:SetScript("OnEvent", function(self,event)
if event == "PLAYER_XP_UPDATE" then
if GetXPExhaustion() then
f:Show()
end
else
if IsResting() then
f:Hide()
elseif GetXPExhaustion() then
f:Show()
end
end
end)
  Reply With Quote
06-29-11, 11:27 PM   #10
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,336
I don't see a fontstring:SetPoint() in the code.
Try adding this somewhere after the frame:CreateFontstring() call.
Code:
fs:SetPoint("CENTER");
This will tell it to set the center point of the FontString on the center reference point of the default object (its parent) with no offset.

Note: The existing fontstring:SetJustifyH() call does not stand in for fontstring:SetPoint(). It's meant to define the text alignment within the FontString object. This is more effective when there are multiple lines of text in the same FontString.
__________________
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
06-30-11, 11:38 AM   #11
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
/facepalm
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-30-11, 12:03 PM   #12
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Just want to share my thoughts, for e.g. noobs like me, even making simple frames still looks very hard to do, and I easily get completely lost in all this SetJustifyH and FontStrings stuff

I feel like, everytime code examples with a lot of frame/widget stuff are posted, they look just fine until someone points out some rather "obvious" error :s
  Reply With Quote
06-30-11, 09:11 PM   #13
Tadedra
A Cliff Giant
Join Date: Dec 2010
Posts: 70
What I have is this:
Code:
local f = CreateFrame("Frame")
f:SetSize(100,15)
f:SetPoint("TOP",0,-200)
f:Hide()
local fs = f:CreateFontString(nil,nil,"GameFontNormalLarge")
fs:SetPoint("CENTER")
fs:SetJustifyH("CENTER")
fs:SetText("You are out of rested experience!")

f:RegisterEvent("PLAYER_XP_UPDATE")
f:RegisterEvent("PLAYER_UPDATE_RESTING")
f:SetScript("OnEvent", function(self,event)
     if event == "PLAYER_XP_UPDATE" then
          if GetXPExhaustion() then
               f:Show()
          end
     else
          if IsResting() then
               f:Hide()
          elseif GetXPExhaustion() then
               f:Show()
          end
     end
end)
So right now, I have the splash of out of rested points but its reacting funny. When I left the inn with rested points the splash came up. I reloaded the UI and the splash went away. Then when I killed something the splash came back (but I still had rested points).

When my rested points were gone the splash was still on the screen. I reloaded the UI and the splash went away. I killed a few things and it didn't come back.

I'm thinking its because I have to merge the

local rest=GetXPExhaustion();
if rest<=0 and lastrest>0 then
~ mentioned by SDPhantom but I'm not sure how to do that.
  Reply With Quote
06-30-11, 09:14 PM   #14
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,336
Originally Posted by Ketho View Post
I feel like, everytime code examples with a lot of frame/widget stuff are posted, they look just fine until someone points out some rather "obvious" error :s
Even the best of us make mistakes. I've been playing around with Lua for the last 8 years, that's including the last 5 years with the WoW API. Even before that, I've had a strong background in programming, starting when I was 6 or 7.

All that and I still make the most ridiculous of mistakes in writing code sometimes.
__________________
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
06-30-11, 09:57 PM   #15
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,336
Let's see what I can accomplish.... and I wouldn't suggest even trying to understand it, lol
lua Code:
  1. local frame=CreateFrame("Frame",nil,UIParent);--    Create our frame
  2. frame:SetPoint("TOP",0,-250);-- Set its position
  3.  
  4. --  Our frame doesn't really need any size to it, it just needs these set to be shown
  5. frame:SetWidth(1);
  6. frame:SetHeight(1);
  7.  
  8. local text=frame:CreateFontString(nil,"OVERLAY","GameFontNormalHuge");--    This is the same font used for Raid Warnings
  9. text:SetPoint("CENTER");--  Center to our frame
  10. text:SetTextColor(1,0,0)--  Color our text red
  11. text:SetText("You are out of rested experience!");--    Our text
  12.  
  13. --  Register events
  14. frame:RegisterEvent("PLAYER_LOGIN");--  On login
  15. frame:RegisterEvent("PLAYER_UPDATE_RESTING");-- On entering/exiting a city/inn
  16. frame:RegisterEvent("UPDATE_EXHAUSTION");-- On update to rested exp value
  17.  
  18. --  Our complex handler
  19. frame:SetScript("OnEvent",function(self)
  20. --  This chooses between self:Show() and self:Hide()
  21. --  It's impossible to use the obj:func() call style with a conditional table index
  22. --  We're using the equivalent obj["func"](obj) (aka obj.func(obj)) call instead
  23.     self[(IsResting() or (GetXPExhaustion() or 0)>0) and "Hide" or "Show"](self);
  24. end);
__________________
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)

Last edited by SDPhantom : 06-30-11 at 10:04 PM.
  Reply With Quote
06-30-11, 10:12 PM   #16
Verttex
Super Monkey
 
Verttex's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 297
Originally Posted by SDPhantom View Post
Let's see what I can accomplish.... and I wouldn't suggest even trying to understand it, lol
lua Code:
  1. local frame=CreateFrame("Frame",nil,UIParent);--    Create our frame
  2. frame:SetPoint("TOP",0,-250);-- Set its position
  3.  
  4. --  Our frame doesn't really need any size to it, it just needs these set to be shown
  5. frame:SetWidth(1);
  6. frame:SetHeight(1);
  7.  
  8. local text=frame:CreateFontString(nil,"OVERLAY","GameFontNormalHuge");--    This is the same font used for Raid Warnings
  9. text:SetPoint("CENTER");--  Center to our frame
  10. text:SetTextColor(1,0,0)--  Color our text red
  11. text:SetText("You are out of rested experience!");--    Our text
  12.  
  13. --  Register events
  14. frame:RegisterEvent("PLAYER_LOGIN");--  On login
  15. frame:RegisterEvent("PLAYER_UPDATE_RESTING");-- On entering/exiting a city/inn
  16. frame:RegisterEvent("UPDATE_EXHAUSTION");-- On update to rested exp value
  17.  
  18. --  Our complex handler
  19. frame:SetScript("OnEvent",function(self)
  20. --  This chooses between self:Show() and self:Hide()
  21. --  It's impossible to use the obj:func() call style with a conditional table index
  22. --  We're using the equivalent obj["func"](obj) (aka obj.func(obj)) call instead
  23.     self[(IsResting() or (GetXPExhaustion() or 0)>0) and "Hide" or "Show"](self);
  24. end);
Quick question, As I am a LUA-learner here myself, does
Code:
--	Register events
frame:RegisterEvent("PLAYER_LOGIN");--	On login
frame:RegisterEvent("PLAYER_UPDATE_RESTING");--	On entering/exiting a city/inn
frame:RegisterEvent("UPDATE_EXHAUSTION");--	On update to rested exp value
allow

Code:
self[(IsResting() or (GetXPExhaustion() or 0)>0) and "Hide" or "Show"](self);
to work?
__________________
  Reply With Quote
06-30-11, 10:52 PM   #17
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,336
Originally Posted by Verttex View Post
Quick question, As I am a LUA-learner here myself, does
Code:
--	Register events
frame:RegisterEvent("PLAYER_LOGIN");--	On login
frame:RegisterEvent("PLAYER_UPDATE_RESTING");--	On entering/exiting a city/inn
frame:RegisterEvent("UPDATE_EXHAUSTION");--	On update to rested exp value
allow

Code:
self[(IsResting() or (GetXPExhaustion() or 0)>0) and "Hide" or "Show"](self);
to work?
Yes. The events registered fire through the OnEvent script of the frame.
The script is written to not care which event is fired, it'll just update the showing of the frame.
__________________
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)

Last edited by SDPhantom : 06-30-11 at 10:57 PM.
  Reply With Quote
07-01-11, 01:31 PM   #18
Tadedra
A Cliff Giant
Join Date: Dec 2010
Posts: 70
Thanks for all the team work and back and forth to help work this out. It very helpful with the descriptions too after the coding. I have played a bit with the colors and positioning. Even took a step in for the fonts.

I'm not brave enough for the real event finding but understanding the concepts help me figure out a thing or two.

so thanks again for all your hard work.
  Reply With Quote
07-01-11, 02:10 PM   #19
Verttex
Super Monkey
 
Verttex's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 297
Originally Posted by SDPhantom View Post
Yes. The events registered fire through the OnEvent script of the frame.
The script is written to not care which event is fired, it'll just update the showing of the frame.
But how does the PLAYER_UPDATE_RESTING and UPDATE_EXHAUSTION alias to IsResting and GetXPExhaustion
__________________
  Reply With Quote
07-01-11, 06:52 PM   #20
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,336
Originally Posted by Verttex View Post
But how does the PLAYER_UPDATE_RESTING and UPDATE_EXHAUSTION alias to IsResting and GetXPExhaustion
The events fire when the value to be returned by the associated functions have changed. PLAYER_UPDATE_RESTING fires when the value from IsResting() changes just like UPDATE_EXHAUSTION fires when the value from GetXPExhaustion() changes.
__________________
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

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Red flag for "you feel normal"


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