WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Securely setting a global variable (https://www.wowinterface.com/forums/showthread.php?t=56117)

Kanegasi 03-22-18 05:30 PM

Securely setting a global variable
 
I have the following code:

Lua Code:
  1. function PLAYER_LOGIN()
  2.  
  3.     BUFFS_PER_ROW=12
  4.     BUFF_MAX_DISPLAY=36
  5.     BUFF_HORIZ_SPACING=-1.25
  6.  
  7. end


This works great, however I get the following silly error when I try to rightclick buffs in combat:

Code:

Message: Note: AddOn attempted to call a protected function (CancelUnitBuff()) during combat lockdown.
Debug:
  [C]: CancelUnitBuff()
  ..\FrameXML\BuffFrame.lua:280: BuffButton_OnClick()
  [string "*:OnClick"]:1:
      [string "*:OnClick"]:1


I'm not altering these in combat. The values do not change beyond login. Is there a secure way to change these three variables?

I am not interested in any buff addons. I just want to change these three global variables once each session.

MunkDev 03-23-18 10:07 AM

Doesn't matter if you change them in combat or not, you've still tainted these globals.
If the stuff you want to move around isn't secure, you should probably hook the functions that control the layout and alter the layout that way.

Kanegasi 03-23-18 02:46 PM

I donít think thereís any functions tied to those variables. Theyíre directly set and used in BuffFrame.lua. Thanks for your help anyways.

MunkDev 03-23-18 03:07 PM

Quote:

Originally Posted by Kanegasi (Post 327336)
I donít think thereís any functions tied to those variables.

These are both globals you can hook and apply your changes afterwards.
You could just copy the contents of these functions into your hook and replace the globals used with your own locals.
Lua Code:
  1. BuffFrame_UpdateAllBuffAnchors
  2. DebuffButton_UpdateAnchors

Seerah 03-23-18 06:50 PM

ShinyBuffs edits BUFFS_PER_ROW with no issue. So it may be one of the other two. Have you tried narrowing down which?

Kanegasi 03-24-18 12:38 PM

Quote:

Originally Posted by Seerah (Post 327339)
ShinyBuffs edits BUFFS_PER_ROW with no issue. So it may be one of the other two. Have you tried narrowing down which?

I didn't think it would just be one or two of them. I immediately assumed it was the spacing one since it's used in buff:SetPoint. To my surprise, the max display is what's causing the rightclick block, and I have no idea why.

Here's all five mentions of the variable in the entire extract:

Code:

..Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua (3 hits)
        Line 492:                for i = 1, BUFF_MAX_DISPLAY do
        Line 513:                for i = 1, BUFF_MAX_DISPLAY do
        Line 540:                for i = buffIndex, BUFF_MAX_DISPLAY do
..Interface\FrameXML\BuffFrame.lua (2 hits)
        Line 7: BUFF_MAX_DISPLAY = 32;
        Line 90:        for i=1, BUFF_MAX_DISPLAY do

I'm going to assume the nameplate code is causing a taint just by proxy. I originally wanted three even rows of 12, looks like I'll have to settle with three rows of 11 with one spot missing. Getting to max buffs is super rare anyways.

Resike 03-24-18 01:32 PM

Quote:

Originally Posted by Seerah (Post 327339)
ShinyBuffs edits BUFFS_PER_ROW with no issue. So it may be one of the other two. Have you tried narrowing down which?

Just because you can override their values that doesn't mean that you should. As you can see you did nothing wrong here and the game still locks you down.

If you override SECOND_ONELETTER_ABBR, every time any kind of cooldown object gets updated in your UI, a global taint will run by the game, you can guess the overhead that could cause.
See related: http://www.wowinterface.com/download....html#comments


All times are GMT -6. The time now is 11:32 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI