WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Macro Help (https://www.wowinterface.com/forums/forumdisplay.php?f=140)
-   -   Make this script work in combat? (https://www.wowinterface.com/forums/showthread.php?t=45921)

Dynamicz 03-03-13 03:49 AM

Make this script work in combat?
 
/run local f={PlayerFrame} for i=1,#f do f[i]:EnableMouse(0)end

This makes it so I can click through my player frame but I want to use this in combat. How do I do this?

Phanx 03-03-13 04:22 AM

Not possible. You cannot modify the mouse-enabled state of secure frames while in combat. The best you could do would be to enable the mouse when you enter combat, and disable it again when you leave.

Also, that is a horribly written macro. I'm guessing you found it, or based it on something you found, on ArenaJunkies. You can just do this instead:

Code:

/run PlayerFrame:EnableMouse(false)
If you want it to be a toggle:

Code:

/run PlayerFrame:EnableMouse(not PlayerFrame:IsMouseEnabled())
If you want to automatically enable the mouse during combat, and disable it out of combat:

Code:

local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_REGEN_ENABLED")
f:RegisterEvent("PLAYER_REGEN_DISABLED")
f:SetScript("OnEvent", function()
    if InCombatLockdown() then return end
    PlayerFrame:EnableMouse(UnitAffectingCombat("player"))
end)

If you need help turning the above code into an addon, copy and paste it into this page:
http://addon.ziuo.net/

Sharparam 03-03-13 10:40 AM

Quote:

Originally Posted by Phanx (Post 273859)
If you want it to be a toggle:

Code:

/run PlayerFrame:EnableMouse(PlayerFrame:IsMouseEnabled())

Shouldn't that be "not PlayerFrame:IsMouseEnabled()" in order to toggle it? :)

ravagernl 03-03-13 11:48 AM

Quote:

Originally Posted by F16Gaming (Post 273868)
Shouldn't that be "not PlayerFrame:IsMouseEnabled()" in order to toggle it? :)

Quoted for truth.

A more fitting solution would be to enable the mouse based on modifier state (ctrl/shift/alt keys):

lua Code:
  1. local f = CreateFrame("Frame")
  2.  
  3. function f:Event = function()
  4.     if InCombatLockdown() then return end
  5.     PlayerFrame:EnableMouse(IsModifierKeyDown())
  6. end
  7.  
  8. function f:Load()
  9.      PlayerFrame:EnableMouse(false)
  10.      self:UnregisterEvent("PLAYER_REGEN_ENABLED")
  11.      self:RegisterEvent("MODIFIER_STATE_CHANGED")
  12.      self:SetScript("OnEvent", f.Event)
  13.      self.Load = nil
  14. end
  15.  
  16. if InCombatLockDown() then
  17.      f:RegisterEvent("PLAYER_REGEN_ENABLED")
  18.      f:SetScript("OnEvent", f.Load)
  19. else
  20.      f:Load()
  21. end

Untested, and probably has errors, but I think something like this would work :)

p3lim 03-03-13 03:17 PM

It's possible to change the attributes on the frames, so you could for example only click the frame if you're holding down shift.

Lua Code:
  1. PlayerFrame:SetAttribute('*type1', nil)
  2. PlayerFrame:SetAttribute('shift-type1', 'target')

Dynamicz 03-03-13 07:06 PM

Quote:

Originally Posted by p3lim (Post 273876)
It's possible to change the attributes on the frames, so you could for example only click the frame if you're holding down shift.

Lua Code:
  1. PlayerFrame:SetAttribute('*type1', nil)
  2. PlayerFrame:SetAttribute('shift-type1', 'target')

That actually sounds a lot better than what I'm trying to do. How do I put this in the game? To be honest I'm not too familiar with all this.

Phanx 03-03-13 11:03 PM

Fixed the missing "not" in my original post.

Quote:

Originally Posted by p3lim (Post 273876)
It's possible to change the attributes on the frames, so you could for example only click the frame if you're holding down shift.

Lua Code:
  1. PlayerFrame:SetAttribute('*type1', nil)
  2. PlayerFrame:SetAttribute('shift-type1', 'target')

That doesn't affect the frame's mouse-interactability, though. You still can't click through the frame. All the click attributes do is change what happens when you click on the frame. Using the above code, clicking on the frame without holding Shift would simply create a "dead zone" where clicks did nothing at all.

A better overall solution might be to simply move the frames to some part of the screen you aren't accidentally clicking all the time.

p3lim 03-04-13 08:50 AM

Quote:

Originally Posted by Dynamicz (Post 273887)
That actually sounds a lot better than what I'm trying to do. How do I put this in the game? To be honest I'm not too familiar with all this.

Use it in a macro, prefixed with /run.
Or better, make an addon out of it: http://addon.ziuo.net/

ravagernl 03-04-13 11:19 AM

Hmm, this got me thinking... Would this not be possible with a custom state, or are custom states not allowed on unitframes (Is SecureUnitButtonTemplate inheriting attributes/methods of SecureHandlerStateTemplate)?

lua Code:
  1. PlayerFrame:SetAttribute("_onstate-mousestate", [[
  2.     self:EnableMouse(newstate == "enabled")
  3. ]]);
  4. -- Normal, not listening to shift
  5. RegisterStateDriver(PlayerFrame, "mousestate", "[combat] disabled; enabled");
  6. -- Disable clicking in combat unless ctrl/shift/alt is pressed
  7. -- RegisterStateDriver(PlayerFrame, "mousestate", "[mod] enabled; [combat] disabled; enabled");

p3lim 03-04-13 01:07 PM

Yes, although I'm not sure if you can use it on PlayerFrame or not, and not sure about :EnableMouse() inside the wrapper.

Dynamicz 03-04-13 01:19 PM

Quote:

Originally Posted by ravagernl (Post 273911)
Hmm, this got me thinking... Would this not be possible with a custom state, or are custom states not allowed on unitframes (Is SecureUnitButtonTemplate inheriting attributes/methods of SecureHandlerStateTemplate)?

lua Code:
  1. PlayerFrame:SetAttribute("_onstate-mousestate", [[
  2.     self:EnableMouse(newstate == "enabled")
  3. ]]);
  4. -- Normal, not listening to shift
  5. RegisterStateDriver(PlayerFrame, "mousestate", "[combat] disabled; enabled");
  6. -- Disable clicking in combat unless ctrl/shift/alt is pressed
  7. -- RegisterStateDriver(PlayerFrame, "mousestate", "[mod] enabled; [combat] disabled; enabled");

If this worked then it would help me with what I'm trying to do. I was just using "PlayerFrame" as an example I really wanted get a code that would make it so that I could click through raid frames during combat unless a modifier is being used like shift,ctrl,alt. Instead of "PlayerFrame" it would be "CompactRaidGroup1Member1" (I would actually have to do it for every raid member up to 10 because I just want it for 10 mans so CompactRaidGroup1Member2, CompactRaidGroup1Member3 etc).

I just tried this and it didn't work for PlayerFrame and I tried in and out of combat.


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

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