WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Determining if I am in a raid group. (https://www.wowinterface.com/forums/showthread.php?t=45074)

Wowguy25 11-05-12 02:40 PM

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.

Dridzt 11-05-12 04:05 PM

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/

Haleth 11-05-12 05:00 PM

Quote:

Originally Posted by Dridzt (Post 268406)
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. :)

Dridzt 11-05-12 05:05 PM

Quote:

Originally Posted by Haleth (Post 268408)
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.

Phanx 11-05-12 05:28 PM

Maybe I'm missing something, but doesn't the use of "not" already guarantee a boolean result?

Vlad 11-05-12 05:39 PM

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. :)

Dridzt 11-05-12 06:13 PM

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.

Wowguy25 11-05-12 06:17 PM

Quote:

Originally Posted by Dridzt (Post 268409)
(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.

Farmbuyer 11-06-12 12:15 AM

Quote:

Originally Posted by Dridzt (Post 268418)
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.


All times are GMT -6. The time now is 10:05 PM.

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