Thread Tools Display Modes
03-03-13, 03:49 AM   #1
Dynamicz
A Defias Bandit
Join Date: Mar 2013
Posts: 3
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?
  Reply With Quote
03-03-13, 04:22 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
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/
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 03-03-13 at 11:01 PM.
  Reply With Quote
03-03-13, 10:40 AM   #3
Sharparam
A Flamescale Wyrmkin
 
Sharparam's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2011
Posts: 102
Originally Posted by Phanx View Post
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? :)
  Reply With Quote
03-03-13, 11:48 AM   #4
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Originally Posted by F16Gaming View Post
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

Last edited by ravagernl : 03-03-13 at 11:56 AM.
  Reply With Quote
03-03-13, 03:17 PM   #5
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
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')

Last edited by p3lim : 03-03-13 at 03:22 PM.
  Reply With Quote
03-03-13, 07:06 PM   #6
Dynamicz
A Defias Bandit
Join Date: Mar 2013
Posts: 3
Originally Posted by p3lim View Post
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.
  Reply With Quote
03-03-13, 11:03 PM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Fixed the missing "not" in my original post.

Originally Posted by p3lim View Post
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.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
03-04-13, 08:50 AM   #8
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Dynamicz View Post
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/
  Reply With Quote
03-04-13, 11:19 AM   #9
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
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");

Last edited by ravagernl : 03-04-13 at 11:36 AM. Reason: grammar biatch!
  Reply With Quote
03-04-13, 01:07 PM   #10
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Yes, although I'm not sure if you can use it on PlayerFrame or not, and not sure about :EnableMouse() inside the wrapper.
  Reply With Quote
03-04-13, 01:19 PM   #11
Dynamicz
A Defias Bandit
Join Date: Mar 2013
Posts: 3
Originally Posted by ravagernl View Post
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.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » Macro Help » Make this script work in combat?

Thread Tools
Display Modes

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