Thread Tools Display Modes
08-16-24, 11:32 AM   #1
Zax
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 164
Lua error when retrieving protected frame width?

Hello,

I use this code to retrieve infos of frames under the mouse cursor:
Lua Code:
  1. function frameSpecs()
  2.     local function getFrameInfos(f)
  3.         local tmp = f:GetName()
  4.         if (tmp ~= nil) then
  5.             return tmp.."--- "..f:GetObjectType().." "..floor(f:GetWidth()).." x "..floor(f:GetHeight()).." px --- alpha = "..f:GetAlpha().." ("..f:GetEffectiveAlpha()..")"
  6.         else
  7.             return nil
  8.         end
  9.     end
  10.    
  11.     local thisFrame = EnumerateFrames()
  12.     while thisFrame do
  13.         if (MouseIsOver(thisFrame) and thisFrame:IsVisible()) then
  14.             local tmp = getFrameInfos(thisFrame)
  15.             if (tmp ~= nil) then print(getFrameInfos(thisFrame)) end
  16.         end
  17.         thisFrame = EnumerateFrames(thisFrame)
  18.     end
  19. end
It works fine but raises a lua error if the frame is protected when retrieving its width.

Is it normal for such a getter function to raise an error?
Is there a way for this function to print an error string instead of generating a big lua error?
__________________
Zax - Addons List, not all maintained.
  Reply With Quote
08-16-24, 12:15 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 6,007
This link include 2 possible functions you could check for potential issues before trying ..

https://warcraft.wiki.gg/wiki/Object...bidden_objects

Namely IsProtected and IsForbidden.
__________________


All Level 70 Characters:
Demon Warlock
Resto Druid
Disc Priest
Resto Shaman
Survival Hunter
Augment Evoker
Frost Mage
Vengence Demon Hunter
Rogue ( was subtlety )

Brewmaster Monk (TR)
Prot Paladin (TR)
Blood Death Knight ( TR)

As you can see I am missing a warrior

And .. I don't have all the allied races covered. Time Runner time when it happens again

  Reply With Quote
08-17-24, 01:10 AM   #3
Zax
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 164
Thanks.

Even if I use IsProtected() or IsForbidden(), the script still raises a lua error but I think the error comes from MouseIsOver().
The script worked fine on all frames with WoW 10.x, so I guess it is now incompatible with WoW 11.

Even a shortened version like the following no longer works:
Lua Code:
  1. local thisFrame = EnumerateFrames()
  2.     while thisFrame do
  3.         if (MouseIsOver(thisFrame)) then
  4.               print(thisFrame:GetName())
  5.         end
  6.         thisFrame = EnumerateFrames(thisFrame)
  7.     end
__________________
Zax - Addons List, not all maintained.
  Reply With Quote
08-17-24, 05:48 AM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 6,007
I wonder if it's linked to the mouse changes

https://warcraft.wiki.gg/wiki/Patch_...ut_propagation

But can't see any other complaints about it, despite using it in recent months.

You could the function that function calls in case that makes a difference

Lua Code:
  1. function MouseIsOver(region, topOffset, bottomOffset, leftOffset, rightOffset)
  2.     return region:IsMouseOver(topOffset, bottomOffset, leftOffset, rightOffset);
  3. end

Maybe they don't want you to use their function but you can use the api function. fingers crossed
__________________


All Level 70 Characters:
Demon Warlock
Resto Druid
Disc Priest
Resto Shaman
Survival Hunter
Augment Evoker
Frost Mage
Vengence Demon Hunter
Rogue ( was subtlety )

Brewmaster Monk (TR)
Prot Paladin (TR)
Blood Death Knight ( TR)

As you can see I am missing a warrior

And .. I don't have all the allied races covered. Time Runner time when it happens again

  Reply With Quote
08-17-24, 05:57 AM   #5
Zax
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 164
[quote=Xrystal;344318]
Lua Code:
  1. function MouseIsOver(region, topOffset, bottomOffset, leftOffset, rightOffset)
  2.     return region:IsMouseOver(topOffset, bottomOffset, leftOffset, rightOffset);
  3. end
Originally Posted by Huge Lua error
Message: StatusBar:IsMouseOver(): Action[FrameMeasurement] failed because[Can't measure restricted regions]: attempted from: StatusBar:IsMouseOver().
Thanks anyway.
__________________
Zax - Addons List, not all maintained.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Lua error when retrieving protected frame width?


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