Thread Tools Display Modes
11-05-12, 02:40 PM   #1
Wowguy25
A Deviate Faerie Dragon
Join Date: Nov 2012
Posts: 17
Determining if I am in a raid group.

I need to make a custom trigger for some of my auras in weakauras. What I want it to do is to prevent the trigger from triggering if I am in a raid group (but not if I am in a party or solo). Weakauras accepts lua for custom triggers but seeing as I am a total noob at lua I am in need of some help.

I suspect I could use UnitInRaid("player") but I have no idea how to construct an actual lua function with it.
  Reply With Quote
11-05-12, 04:05 PM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
I believe you could accomplish that with the Load conditions without writing a custom trigger.

On the Load tab you'll find "Instance Type".
Checking it allows you to pick one from dropdown, clicking it again presents you with a multiple checkbox section for all instance types.
Just check the ones you want the aura to load in and leave the rest unchecked.

Custom trigger is also relatively easy.
You'd want
Custom Trigger:
Code:
function()
  return not IsInRaid() and true
end
Custom Untrigger:
Code:
function()
  return true
end
Generally speaking the dedicated WeakAuras forum is a better place for usage tips and self-help from the community.

This set of pages is also a good resource:
http://www.wowace.com/addons/weakauras/pages/

Last edited by Dridzt : 11-05-12 at 04:08 PM.
  Reply With Quote
11-05-12, 05:00 PM   #3
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Originally Posted by Dridzt View Post
Code:
function()
  return not IsInRaid() and true
end
The and-operator here is redundant. You're comparing either 'false and true' or 'true and true'. Just 'not InInRaid()' should do.
  Reply With Quote
11-05-12, 05:05 PM   #4
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Originally Posted by Haleth View Post
The and-operator here is redundant. You're comparing either 'false and true' or 'true and true'. Just 'not InInRaid()' should do.
In the general case that's correct but that's not how custom WeakAuras triggers evaluate.
It needs to be like that. (I should know as I've been doing maintenance work on it after MoP hit)

It's good practice to make sure you return a boolean as you won't be left wondering why they don't work when you rely on 1 or 0 being true.
  Reply With Quote
11-05-12, 05:28 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Maybe I'm missing something, but doesn't the use of "not" already guarantee a boolean result?
__________________
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
11-05-12, 05:39 PM   #6
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
Actually using the word "not" will always return a boolean value. "not nil" will become true and "not 0" will become false - so strictly speaking it should work just like, like Haleth mentioned.
__________________
Profile: Curse | Wowhead
  Reply With Quote
11-05-12, 06:13 PM   #7
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
You're not missing anything guys, I maybe worded it wrong, it is redundant in this particular case but users trying to write custom triggers in WeakAuras are best served by having a habit of making sure their custom trigger and untrigger functions return boolean true.

For example while if 1|0|table|'text' then will all evaluate to true for the purpose of the control structure they will not produce the desired result as part of a WeakAura trigger.

My reply was pertaining to the specific addon not Lua code in general, sorry for the confusion.
  Reply With Quote
11-05-12, 06:17 PM   #8
Wowguy25
A Deviate Faerie Dragon
Join Date: Nov 2012
Posts: 17
Originally Posted by Dridzt View Post
(I should know as I've been doing maintenance work on it after MoP hit)
Thanks for your lua codes they work great! Since you seem like an expert on weakauras maybe you could help me with a new problem that just presented itself. I need to use full scan with spellID to detect spirit shell on my raid members because the shield buff and the buff from activating the ability itself have the same name. However I just noticed that you can not use unit id's for full scan, only player, target, focus or pet. Is there a reason for this? Ie is it just impossible? Or would it be possible for instance to make a custom trigger that could check for a specific spellID on a specific unit id?

Edit: Never mind! I found I was able to get around this by putting in the unit ID before I turned on full scan and it works. Still curious why the options are limited when you put on full scan though.

Last edited by Wowguy25 : 11-05-12 at 06:33 PM.
  Reply With Quote
11-06-12, 12:15 AM   #9
Farmbuyer
A Cyclonian
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 43
Originally Posted by Dridzt View Post
You're not missing anything guys, I maybe worded it wrong, it is redundant in this particular case but users trying to write custom triggers in WeakAuras are best served by having a habit of making sure their custom trigger and untrigger functions return boolean true.
That could be made infinitely more robust by having the WeakAuras calling code force the function return value to boolean, rather than relying on all its users to remember to do so. I'm surprised it hasn't already been done.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Determining if I am in a raid group.


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