EQ2Interface.com
Search Downloads


Go Back   EQ2Interface > Developer Discussion > XML Modification Help & Info

Reply
Thread Tools Search this Thread Display Modes
  #1  
Unread 09-20-2010, 02:54 AM
gdujj gdujj is offline
A Brown Bear
 
Join Date: Sep 2010
Server: Unkown
Posts: 11
Default 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!

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).
Reply With Quote
  #2  
Unread 09-20-2010, 06:19 AM
gm9 gm9 is offline
gm10-1
Premium Member
EQ2Interface Super Mod
Featured
 
Join Date: Feb 2006
Posts: 6,479
Default

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.
__________________
P R O F I T U I ∙ R E B O R N [Auto-Updater] | [Portal] | [F.A.Q.] | [Support Forums]
~ Retired ~
If it does not work, you likely installed it incorrectly. Always try a clean install before reporting bugs.
Reply With Quote
  #3  
Unread 09-20-2010, 06:28 AM
gdujj gdujj is offline
A Brown Bear
 
Join Date: Sep 2010
Server: Unkown
Posts: 11
Default

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.

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

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
Reply With Quote
  #4  
Unread 09-20-2010, 06:38 AM
gm9 gm9 is offline
gm10-1
Premium Member
EQ2Interface Super Mod
Featured
 
Join Date: Feb 2006
Posts: 6,479
Default

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.
__________________
P R O F I T U I ∙ R E B O R N [Auto-Updater] | [Portal] | [F.A.Q.] | [Support Forums]
~ Retired ~
If it does not work, you likely installed it incorrectly. Always try a clean install before reporting bugs.
Reply With Quote
  #5  
Unread 09-20-2010, 06:51 AM
gdujj gdujj is offline
A Brown Bear
 
Join Date: Sep 2010
Server: Unkown
Posts: 11
Default

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!
Reply With Quote
  #6  
Unread 09-20-2010, 07:21 AM
gm9 gm9 is offline
gm10-1
Premium Member
EQ2Interface Super Mod
Featured
 
Join Date: Feb 2006
Posts: 6,479
Default

Quote:
Originally Posted by gdujj View Post
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.
__________________
P R O F I T U I ∙ R E B O R N [Auto-Updater] | [Portal] | [F.A.Q.] | [Support Forums]
~ Retired ~
If it does not work, you likely installed it incorrectly. Always try a clean install before reporting bugs.
Reply With Quote
  #7  
Unread 09-20-2010, 10:45 AM
EQAditu's Avatar
EQAditu EQAditu is offline
A Griffon
Interface Author - Click to view interfaces
 
Join Date: Mar 2005
Server: Permafrost
Posts: 256
Default

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".
Reply With Quote
  #8  
Unread 09-20-2010, 01:45 PM
Drumstix42's Avatar
Drumstix42 Drumstix42 is offline
A Griffon
Featured
 
Join Date: Oct 2004
Server: Antonia Bayle
Posts: 3,287
Default

If you edit the code in the UIBuilder it'll automatically put everything on one line with the "newline" separator entity for you.
__________________
"I'm afraid you're guilty of thought-crime. Don't bother getting the door, we'll let ourselves in..."
<Donate to DrumsUI> < [DrumsUI] Updater > < [DrumsUI] Full Interface> < Drumstix42 on Twitch.tv
>
Reply With Quote
  #9  
Unread 09-20-2010, 02:11 PM
gm9 gm9 is offline
gm10-1
Premium Member
EQ2Interface Super Mod
Featured
 
Join Date: Feb 2006
Posts: 6,479
Default

Quote:
Originally Posted by EQAditu View Post
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.
__________________
P R O F I T U I ∙ R E B O R N [Auto-Updater] | [Portal] | [F.A.Q.] | [Support Forums]
~ Retired ~
If it does not work, you likely installed it incorrectly. Always try a clean install before reporting bugs.
Reply With Quote
  #10  
Unread 09-20-2010, 04:12 PM
gdujj gdujj is offline
A Brown Bear
 
Join Date: Sep 2010
Server: Unkown
Posts: 11
Default

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

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 ("&#xD;&#xA;") 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

(now onto the more complicated stuff )
Reply With Quote
Reply



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
Forum Jump


All times are GMT -5. The time now is 04:48 PM.


Our Network
EQInterface | EQ2Interface | WoWInterface | LoTROInterface | ESOUI | MMOUI