1. #1

    Weakaura Help if then statement

    Hey all, long time no talk.

    I need help with an if-then statement. Here is what I have:

    Code:
    function()    local myFactionnum = GetBattlefieldArenaFaction()
        if myFactionnum == "1" then
            myFaction = "Alliance"
        else myFaction = "Horde"
            return myFaction
        end
    end
    It always shows "Horde" however the 0 and 1 result is correct. I haven't worked with WAs in a while and just cannot wrap my brain around this.

  2. #2
    It looks to me like the problem is that you're using "1" instead of just 1, which probably won't work without implicit conversion. It thinks the "1" is a string, not a number so it'll never match to the number 1 that's returned.

  3. #3
    Quote Originally Posted by Biomega View Post
    It looks to me like the problem is that you're using "1" instead of just 1, which probably won't work without implicit conversion. It thinks the "1" is a string, not a number so it'll never match to the number 1 that's returned.

    Changed a few things, so something like this? (it's not working still)

    Code:
    function()    local myFaction = ""
        local myFactionnum = GetBattlefieldArenaFaction()
        if myFactionnum == 1 then
            myFaction = "Alliance"
        else myFaction = "Horde"
            return myFaction
        end
    end
    - - - Updated - - -

    And I have this in display, should it be a trigger instead?

  4. #4
    Code:
    function()
        return GetPlayerFactionGroup()
    end

    OR

    Code:
    function()
        return UnitFactionGroup("player")
    end

    I'm not quite sure how either of these work with mercenary mode for battlegrounds. The code is vague. If you don't switch factions for BGs, then either one of the options above will work fine for you. If you do regularly choose mercenary mode, one of these will report your "real" faction and the other will report your temporary faction.
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

  5. #5
    Quote Originally Posted by kanegasi View Post
    Code:
    function()
        return GetPlayerFactionGroup()
    end

    OR

    Code:
    function()
        return UnitFactionGroup("player")
    end

    I'm not quite sure how either of these work with mercenary mode for battlegrounds. The code is vague. If you don't switch factions for BGs, then either one of the options above will work fine for you. If you do regularly choose mercenary mode, one of these will report your "real" faction and the other will report your temporary faction.
    Sadly neither of those work.

    getplayerfaction group returns: False
    and unit faction group returns alliance while I am horde in WSG.

    - - - Updated - - -

    This as a macro works perfectly every time:

    /script print(UnitFactionGroup("player").." - "..GetBattlefieldArenaFaction())

    I just can't figure out how to add it to a weakaura.

  6. #6
    The only return is nested in the Horde else statement. It can't return alliance because the only return is right before it gets set to horde.
    Code:
    function()    local myFaction = ""
        local myFactionnum = GetBattlefieldArenaFaction()
        if myFactionnum == 1 then
            myFaction = "Alliance"
        else myFaction = "Horde"
        end
        return myFaction
    end
    Last edited by Anuibus; 2025-11-09 at 01:05 AM.

  7. #7
    Quote Originally Posted by Nightmist View Post
    getplayerfaction group returns: False
    It is not possible for GetPlayerFactionGroup() to return false. You are playing on a private server.
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

  8. #8
    Quote Originally Posted by kanegasi View Post
    It is not possible for GetPlayerFactionGroup() to return false. You are playing on a private server.
    Yes, that is correct. So interesting, some of the API is different I guess?

    [Moderator Note: Please avoid mentioning or asking questions about private servers. Private servers are not the focus of this community, and many consider it a waste of time to read about them.]
    Last edited by Tercio; 2025-11-10 at 01:34 PM. Reason: Moderator note.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •