WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   GetWorldStateUIInfo() clarification (https://www.wowinterface.com/forums/showthread.php?t=36163)

Ninkosen 10-23-10 12:13 PM

GetWorldStateUIInfo() clarification
 
Hi so I'm new, and quite a beginner in wow addons, I've looked all over the place, before coming here.

Does this code works ?

Code:

                local _, stateh, scoreh = GetWorldStateUIInfo(2);
                if (stateh == 2 and not hcarrier) or scoreh == 2 then
                        LeaveBattlefield()
                end
                local _, statea, scorea = GetWorldStateUIInfo(1);
                if statea == 2 and scorea == 2 then
                        LeaveBattlefield()
                end

It's a tiny modification I made of Capping. It's supposed to make me leave a battleground if :
- Horde hold the alliance flag and capping doesn't know who is holding it regardless of the score, Or Horde has 2 points out of 3 in the match, no matter what.
- Alliance has 2 points out of 3 and they hold horde flag

Apparently it doesn't do that, as I get out of the BG, if Alliance hold horde flag (and 0-0), when I just join in. It shouldn't.
Don't ask me why I want to do that, long story.

The score is a string ? does my scorea == 2 works ?

hcarrier should be nul at this point of the execution...

Thanks for any help.

Xubera 10-23-10 12:45 PM

if the score is a string ( logic tells me its a number, but okay) then string == 2 wont work. because "2" does not equal 2.

you could do

score == "2" or tonumber(score) == 2, but worst case, add some prints so you can see whats going on

like

local _, stateh, scoreh = GetWorldStateUIInfo(2);
print(stateh, scoreh, type(scoreh)) --that last bit you can see if scoreh is a string or a number.

edit::
you could even add
print((stateh == 2 and not hcarrier) or scoreh == 2) and it will print true or false (i think, it might print if true and print nothing if false, i forget, you could try print(1==1, 1==2) and see what that yields)

Ninkosen 10-23-10 02:47 PM

ok thanks a lot, this should help

edit: after some time, I figured my problem was that WoWwiki isn't correctly documented, it state that the argument 1 is alliance and 2 is horde... which is false, at least for warsong gulch... it's 2 alliance and 3 horde... 1 being used for the time remaining info... For arathi basin it might be 1 alliance, 2 horde, as there is no time... but it's not always like that

that's why I had weird stuff going on... also the score is indeed a string as documented in wowwiki, like "0/3"

just weird that they say [score]/3, it's a bit confusing...


All times are GMT -6. The time now is 01:29 PM.

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