EQ2Interface

EQ2Interface (https://www.eq2interface.com/forums/index.php)
-   XML Modification Help & Info (https://www.eq2interface.com/forums/forumdisplay.php?f=22)
-   -   Conditionals explanation / dynamic class colours / if statements (https://www.eq2interface.com/forums/showthread.php?t=14743)

gdujj 09-20-2010 02:54 AM

Conditionals explanation / dynamic class colours / if statements
 
Hi there,

I've got my dynamic data inputting into a healthbar; I've filtered that dynamic data to remove the default colours. Great! :D

But all healthbars all now a plan old white color, because I've set "Color='#FFFFFF'".

What I'd really, really love to do is have that Color value change depending on, say, Archetype. I already have this as a text label placed on the healthbar. So on the Archetype's OnTextChange area in the UI builder, I really probably need to do something like this:

OnTextChange="ArchetypeLabel.text="Priest" ? 'HealthBar.Color=#FF000000' : ''"

.. but obviously with 4 conditional statements in there (for priest, fighter, mage and scout). But then it seems inefficient to have the 4 IF statements when really I want 4 conditions, with 1 if and three Elses.

Gah, can someone point me to a working example of this sort of thing so I can expand it for my more complicated purposes? (I've based my above approach on current addons' approach to changing class icons, little images like a shield for a tank, etc, along with searches and looking at the stickies on this forum).

or perhaps there is some way I could say on the HealthBar itself, you know, maybe in OnActivate or OnShow... "if GameData.self.archetype=='Priest' ? 'do priest bg color' : 'nevermind, go to default' else if GameData.self.archetype=='Fighter' ? 'do fighter bg color' : 'nevermind, go to default'... and so on.

Even just a simple example using the above (change font color or bar background based on X, where X is HP value or classtype or whatever, would be good). :confused:

gm9 09-20-2010 06:19 AM

nested conditions do not work (and if you have ever seen my subclass detector or level detecting code you will believe me I wanted them hard), you will need to use 4 statements.

gdujj 09-20-2010 06:28 AM

Hello there, well at least you've confirmed I'm not going mad, i've been looking through these forums sporadically over 4 days looking for examples, downloading raid frames in the hope I spot an example. :o

I guess my questions are therefore:

How IS best to do this sort of thing then? It is surely best to have something on the HealthBar itself saying, perhaps, OnActivate or OnShow, the conditional statement? Is there anything on this topic of where to manage the colouring? I saw some mentions of glitches in previous posts i.e. decisions on this matter can have huge implications later down the line. And most example addons use a hidden text field for Archetype label which in turn manages the little Archetype graphic icon. Seems a strange choice.

Secondly
, even ignoring the "what is most optimal placement/firer manager" question above.. can you give me an example of a working conditional statement using Archetypes (or something else straightforward) with 4 nested IF statements? Then I can use that working example as my starter point. Between my fake code above and guesses of where brackets should be (looking through this forum again) I've not got something fixed yet (I'm sure my attempts are close). :nana:

If I do get it working tonight (at home - I'm at work) I will post an example here for other posters to see. I've seen too many examples of questions posted here where I wanted to know the answer and someone just replied "ok thanks, got it working now" without details of the exact solution :p

gm9 09-20-2010 06:38 AM

I already told you you cannot do nested statements.

Take the archetype icon code you found and do it like they did. Text field is best.

gdujj 09-20-2010 06:51 AM

OK, i had misunderstood, I thought you'd meant I couldn't do the "If... Else If... Else if ... Else if" thing. But I could still do 4 if statements in 1 line of the UI builder (which is what I was aiming for with my second post). Man this is so hard to get into when I don't speak the lingo well! It will come with time.

But this is a bit clearer now!:o

gm9 09-20-2010 07:21 AM

Quote:

Originally Posted by gdujj (Post 93278)
OK, i had misunderstood, I thought you'd meant I couldn't do the "If... Else If... Else if ... Else if" thing. But I could still do 4 if statements in 1 line of the UI builder (which is what I was aiming for with my second post).

No you understood me well then.

EQAditu 09-20-2010 10:45 AM

With how finicky the UI script parser is with doing multiple things in a single statement, I almost never try anymore.

If you can do something like:
result = bool1 ? val1 : bool2 ? val2 : bool3 ? val3 : bool4 ? val4 : badresult
... it's news to me. I'd personally just make it multiple lines of code like:
result = badresult
result = bool1 ? val1 : result
result = bool2 ? val2 : result
result = bool3 ? val3 : result
result = bool4 ? val4 : result


I've been disillusioned by the scripting engine so much that I don't try to write elegant code in it at all. I just do what I know will work and leave the headaches alone. If I really need it to be one line, I just replace every visual newline with the XML entities for new lines, "
". Otherwise known as, "\r\n".

Drumstix42 09-20-2010 01:45 PM

If you edit the code in the UIBuilder it'll automatically put everything on one line with the "newline" separator entity for you.

gm9 09-20-2010 02:11 PM

Quote:

Originally Posted by EQAditu (Post 93283)
With how finicky the UI script parser is with doing multiple things in a single statement, I almost never try anymore.

If you can do something like:
result = bool1 ? val1 : bool2 ? val2 : bool3 ? val3 : bool4 ? val4 : badresult
... it's news to me.

You cannot. But you can still put several statements on one line (right to left) if you are so inclined.

gdujj 09-20-2010 04:12 PM

Right, for future people banging their heads on a desk, looking through threads - here is it totally WORKING :nana::nana::nana:

Code:

Parent.Health.HealthBar.Color=(class_Test ? '#00FF00' : '#FFFFFF') class_Test=(Parent.SubclassLabel.LocalText==Templar)
The above code goes on the OnTextChanged attribute of a text label with the Subclass as its text content (from /Gamedata.Self.Subclass). Then you reference whichever healthbar colour you're trying to change (in my case, a bar called HealthBar on the Health page). The first colour after the ? is if the statement is true (above, if the subclass label is equal to templar), second if my default blank white.

If you place the newline chars ("
") EQAditu posted inbetween more lines (UI builder isn't doing this for me, I was confused but it basically removes any pasted data after a linebreak on my UI Builder), you should be able to add in a line for each subclass. Or Archtype, or whatever else is your defining characteristic.

Thank you so much for your help, guys! I might be a bit slow at getting this, but with all the help/advice being given from posters now, along with the archives of the forums, I'm getting there :D

(now onto the more complicated stuff :p)


All times are GMT -5. The time now is 09:05 PM.

vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI