WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   TargetFrameToT taint? (https://www.wowinterface.com/forums/showthread.php?t=52537)

Jasmer 07-25-15 11:30 AM

TargetFrameToT taint?
 
Hey guys, I'm having a hard time moving my TargetFrameToT. I'm trying to "detach" it from my target frame, basically, and have it display above and to the right so it doesn't overlap my action bars. I really just want to keep it parented to the target frame if I can and just move it a little. Here's a copy of my taint log.

http://pastebin.com/gyQV87xU

I'm really new to this lua stuff (even started reading WoW Programming 2nd Edition) but is this because the ToT frame isn't technically movable? Using SetMovable and SetUserPlaced didn't change anything. This is what I'm using to move the ToT frame.

Lua Code:
  1. TargetFrameToT:ClearAllPoints()
  2. TargetFrameToT:SetPoint("CENTER",TargetFrame,"CENTER", 60,100)
  3. TargetFrameToT.SetPoint = function() end

It's the same way I moved my other UFs but haven't had any errors from them. Pet frame works fine, I've successfully "detached" it from my player frame the same way I'm trying with the ToT frame. I think the fix for this is a little over my head yet, I could really use some help tracking this down :)

Seerah 07-25-15 11:52 AM

This line is your problem that causes taint:
Lua Code:
  1. TargetFrameToT.SetPoint = function() end

Instead, you need to hook it securely:
Lua Code:
  1. local newSetPoint = TargetFrameToT.SetPoint
  2. hooksecurefunc(TargetFrameToT, "SetPoint", function()
  3.           newSetPoint(TargetFrameToT, "CENTER",TargetFrame,"CENTER", 60,100)
  4.      end)

That way, every time the game tries to move the ToT frame, your function will fire immediately after and move it right back. (Note: you may wish to add in a check so that it doesn't try to move it while in combat)

Jasmer 07-25-15 11:56 AM

Quote:

Originally Posted by Seerah (Post 309957)
This line is your problem that causes taint:
Lua Code:
  1. TargetFrameToT.SetPoint = function() end

Instead, you need to hook it securely:
Lua Code:
  1. local newSetPoint = TargetFrameToT.SetPoint
  2. hooksecurefunc(TargetFrameToT, "SetPoint", function()
  3.           newSetPoint(TargetFrameToT, "CENTER",TargetFrame,"CENTER", 60,100)
  4.      end)

That way, every time the game tries to move the ToT frame, your function will fire immediately after and move it right back. (Note: you may wish to add in a check so that it doesn't try to move it while in combat)

Thanks, Seerah, I'll try it out. I'd read the function() end was a problem, but then got confused because I'd also read elsewhere to add it to player and target frames to keep them from resetting. They don't cause any taint problems and they've stopped resetting. Is it because they're actually unlockable, then? Also, the pet frame also has the same function() end and no taint problems as far as I can tell. Kind of confused about this.

As for the combat check, I'll see if I can figure it out. Does that mean it'll reset when I'm in combat, or will it stay where I place it?

Seerah 07-25-15 12:01 PM

I don't know, I don't use the default frames and haven't messed with them beyond using the default UI's method of moving the player and target frames around on PTRs.

Jasmer 07-25-15 02:30 PM

I fixed it! Turns out TargetFrameToT wasn't the source of the taint once I removed
Lua Code:
  1. TargetFrameToT.SetPoint = function() end

However, I kept getting taint issues pointing to that frame. I removed similar lines from all my other frames and used SetMovable and SetUserPlaced. Everything seems to work, with one catch. My pet frame resets to default position unless I add

Lua Code:
  1. PetFrame.SetPoint = function() end

No taint log so far, ToT frame stays where I placed it in combat, so far so good. Does anyone know a better way to keep my pet frame stationary? I tried SetMovable and SetUserPlaced, they didn't work, PetFrame kept resetting. It's working fine with SetPoint = function() end, so far at least, but if this is something that causes taint I'd like a better way to lock my pet frame in place.

semlar 07-25-15 04:12 PM

Quote:

Originally Posted by Jasmer (Post 309959)
Is it because they're actually unlockable, then? Also, the pet frame also has the same function() end and no taint problems as far as I can tell.

When you overwrite a variable or function (like you did) and then blizzard's code runs your function it taints the entire execution path after that point, which means if they have a function that calls TargetFrameToT:SetPoint() after you replaced it then everything in the blizzard function after that point can't do anything that's restricted or protected (like show or hide a unit frame).

Resike 07-25-15 07:22 PM

Quote:

Originally Posted by Jasmer (Post 309961)
I fixed it! Turns out TargetFrameToT wasn't the source of the taint once I removed
Lua Code:
  1. TargetFrameToT.SetPoint = function() end

However, I kept getting taint issues pointing to that frame. I removed similar lines from all my other frames and used SetMovable and SetUserPlaced. Everything seems to work, with one catch. My pet frame resets to default position unless I add

Lua Code:
  1. PetFrame.SetPoint = function() end

No taint log so far, ToT frame stays where I placed it in combat, so far so good. Does anyone know a better way to keep my pet frame stationary? I tried SetMovable and SetUserPlaced, they didn't work, PetFrame kept resetting. It's working fine with SetPoint = function() end, so far at least, but if this is something that causes taint I'd like a better way to lock my pet frame in place.

Hook it, as Seerah mentioned:

Lua Code:
  1. local moving
  2. hooksecurefunc(PetFrame, "SetPoint", function(self)
  3.     if moving then
  4.         return
  5.     end
  6.     moving = true
  7.     self:SetMovable(true)
  8.     self:SetUserPlaced(true)
  9.     self:ClearAllPoints()
  10.     self:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
  11.     self:SetMovable(false)
  12.     moving = nil
  13. end)
  14. PetFrame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)

The big advantage of the SetUserPlaced call if the frame is supported, then you can clear/move protected frames even in combat.

There is also a similar hack with secure frames, where you can resize them in combat while StartSizing is active.

Jasmer 07-25-15 10:28 PM

Okay, thanks for the tip, I'll try it out tonight when I have more time. Sorry for the silly questions, this is all still new to me. I've only read the first couple chapters in that WoW Programming book so if it's not a straightforward clearallpoints, setpoint, etc I'm generally in over my head lol.

Jasmer 07-26-15 10:52 AM

Okay, had a chance to try out the petframe suggestion. It worked, petframe stayed put, but it still caused taint. Near as I can tell it didn't actually cause any problems in the UI, and this is the whole extent of the taint log below. It was only 6 lines, and occurred in the first fight I got into, which was some random elite a few levels above me, so it was long and drawn out.

Code:

7/26 09:25:53.004  Interface\FrameXML\PetActionBarFrame.lua:97
7/26 09:25:53.004  An action was blocked in combat because of taint from JasmerUI - PetActionBarFrame:Hide()
7/26 09:25:53.004      Interface\FrameXML\PetActionBarFrame.lua:99
7/26 09:25:53.211  Interface\FrameXML\PetActionBarFrame.lua:81
7/26 09:25:53.211  An action was blocked in combat because of taint from JasmerUI - PetActionBarFrame:Show()
7/26 09:25:53.211      Interface\FrameXML\PetActionBarFrame.lua:83

I wound up using the following to move both frames, so far no problems. I think the reason it wasn't working for the pet frame earlier is I might not have actually exited the game, just did a /reload, I don't remember though. Either way, only tested on my hunter and rogue. No taint log, frames stay put now.

Lua Code:
  1. PetFrame:SetMovable(true)
  2. PetFrame:ClearAllPoints()
  3. PetFrame:SetPoint("CENTER", PlayerFrame, "CENTER", -60, 100)
  4. PetFrame:SetUserPlaced(true)
  5. PetFrame:SetMovable(false)
  6.  
  7. TargetFrameToT:SetMovable(true)
  8. TargetFrameToT:ClearAllPoints()
  9. TargetFrameToT:SetPoint("CENTER", TargetFrame, "CENTER", 60, 100)
  10. TargetFrameToT:SetUserPlaced(true)
  11. TargetFrameToT:SetMovable(false)

I feel like I'd prefer to hook them but the ToT frame wouldn't move at all when I did, trying both Seerah's suggestion and adapting Resike's to TargetFrameToT. I just woke up after a really long night at work though so blonde moments may have happened and I may have goofed it up. The suggested hook for the PetFrame caused the above mentioned taint, however small it seems to be. I'll try them again tomorrow morning after work when I have time to play, on a fresh restart and game load and everything.

Resike 07-26-15 12:04 PM

Quote:

Originally Posted by Jasmer (Post 309973)
Okay, had a chance to try out the petframe suggestion. It worked, petframe stayed put, but it still caused taint. Near as I can tell it didn't actually cause any problems in the UI, and this is the whole extent of the taint log below. It was only 6 lines, and occurred in the first fight I got into, which was some random elite a few levels above me, so it was long and drawn out.

Code:

7/26 09:25:53.004  Interface\FrameXML\PetActionBarFrame.lua:97
7/26 09:25:53.004  An action was blocked in combat because of taint from JasmerUI - PetActionBarFrame:Hide()
7/26 09:25:53.004      Interface\FrameXML\PetActionBarFrame.lua:99
7/26 09:25:53.211  Interface\FrameXML\PetActionBarFrame.lua:81
7/26 09:25:53.211  An action was blocked in combat because of taint from JasmerUI - PetActionBarFrame:Show()
7/26 09:25:53.211      Interface\FrameXML\PetActionBarFrame.lua:83

I wound up using the following to move both frames, so far no problems. I think the reason it wasn't working for the pet frame earlier is I might not have actually exited the game, just did a /reload, I don't remember though. Either way, only tested on my hunter and rogue. No taint log, frames stay put now.

Lua Code:
  1. PetFrame:SetMovable(true)
  2. PetFrame:ClearAllPoints()
  3. PetFrame:SetPoint("CENTER", PlayerFrame, "CENTER", -60, 100)
  4. PetFrame:SetUserPlaced(true)
  5. PetFrame:SetMovable(false)
  6.  
  7. TargetFrameToT:SetMovable(true)
  8. TargetFrameToT:ClearAllPoints()
  9. TargetFrameToT:SetPoint("CENTER", TargetFrame, "CENTER", 60, 100)
  10. TargetFrameToT:SetUserPlaced(true)
  11. TargetFrameToT:SetMovable(false)

I feel like I'd prefer to hook them but the ToT frame wouldn't move at all when I did, trying both Seerah's suggestion and adapting Resike's to TargetFrameToT. I just woke up after a really long night at work though so blonde moments may have happened and I may have goofed it up. The suggested hook for the PetFrame caused the above mentioned taint, however small it seems to be. I'll try them again tomorrow morning after work when I have time to play, on a fresh restart and game load and everything.

When did the taint occour?

I tried my code in the PTR and it was working fine for me, i could enter leave combat shoot things, even use the pet bar, without any issue. Ofc i didn't tested it entierely like messing with dropdowns/entering queues which could ponentionally spread taints more, this requires more time. But if your code working as intended and not causing any issues then you should stick with it, as long as it works perfectly.

Jasmer 07-26-15 11:25 PM

Okay, tested Resike's code on a fresh start. I'm on a live realm, no PTR, in Shadowmoon Valley, tested on my hunter. Pet frame and ToT frame stayed put in several little fights. Didn't try LFD or anything, though. So far so good, though, and I think I like this method a little better.

Lua Code:
  1. local moving
  2. hooksecurefunc(PetFrame, "SetPoint", function(self)
  3.     if moving then
  4.         return
  5.     end
  6.     moving = true
  7.     self:SetMovable(true)
  8.     self:SetUserPlaced(true)
  9.     self:ClearAllPoints()
  10.     self:SetPoint("CENTER", PlayerFrame, "CENTER", -60, 100)
  11.     self:SetMovable(false)
  12.     moving = nil
  13. end)
  14. PetFrame:SetPoint("CENTER", PlayerFrame, "CENTER", -60, 100)
  15.  
  16. hooksecurefunc(TargetFrameToT, "SetPoint", function(self)
  17.     if moving then
  18.         return
  19.     end
  20.     moving = true
  21.     self:SetMovable(true)
  22.     self:SetUserPlaced(true)
  23.     self:ClearAllPoints()
  24.     self:SetPoint("CENTER", TargetFrame, "CENTER", 60, 100)
  25.     self:SetMovable(false)
  26.     moving = nil
  27. end)
  28. TargetFrameToT:SetPoint("CENTER", TargetFrame, "CENTER", 60, 100)

Here's what it looks like, and it's working fine.



Thanks again guys!

Lombra 07-27-15 04:54 AM

Do you actually need the hooks? I can't find anywhere in the UI where these frames get moved around, except PetFrame once on load.

Jasmer 07-28-15 12:13 PM

It is for the pet frame apparently. Not hooking it still works on my hunter, but my warlock pet resets to default if I don't.


All times are GMT -6. The time now is 04:47 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI