Working IF statements!
1 Attachment(s)
I need to go to work in a few minutes. I leave it to you to do something cool while I'm away.
<Button A="10" B="20" OnPress="Parent.Bool.Visible=(A)<(B)" ... <Page OnShow="(script)" OnHide="(script)" Yup, that's how you do IF statements. You set an event-triggering Boolean (aka true/false) property to the true/false value of the statement, and put a script in the object's corresponding event. Supported operators: == < > Not supported directly: != (Replace with Parent.Bool.Visible=(!(A)==(B)) <= (Replace with Parent.Bool.Visible=(!(A)>(B)) >= (Replace with Parent.Bool.Visible=(!(A)<(B)) (I may be using more parenthesis than I actually need.) One step closer to world domination! Attached demonstration Persona window that doesn't do anything useful. And you can see that I stumbled on this while attempting to combine text strings. :p |
omg this is so awesome!!!! sorry i cant help myself
|
You'll have to explain a bit more with the example, since me finding it on my own would probably take a bit :rolleyes: Good find nonetheless if it can be used.
|
So
<Button A="/GameData.Self.Power" B="50" OnPress="Emoter.Bool.Visible=(A)>(B)" } <Page Name="Emoter" OnShow="laugh" OnHide="cry" } is the equivalent of IF GameData.Self.Power > 50 THEN laugh ELSE cry ? |
Guess not. Trying a different way
|
That should prove usefull :D
Hehe, personally I'd use a button with Activated as the switch. Hierbrand, other than the flubbed bracket at the end, that should work unless gamedata.self.power returns a string it can't compair to a number. |
Hmmm... now to figure out && and || ! :o
|
Quote:
IF ((A == true) && (B == true)) { DoThis } is the same as IF (A == TRUE) { IF (B == true) { DoThis }} and IF ((A == true) || (B == true)) { DoThat } is the same as IF (A == true) { DoThat } IF (B == true) { DoThat } So while it isn't as efficient, we don't need to figure out how to use && and ||. Edit: while the above would work for IF-THENs, IF-THEN-ELSEs get a bit more complicated. Examples: For &&: IF (A == true) { IF (B == true) { DoThis; DoneThis = true }} IF !(DoneThis == true) { DoTheOther } For ||: IF (A == true) { DoThat; DoneThat = true } IF (B == true) { DoThat; DoneThat = true } IF !(DoneThat == true) { DoTheOtherOther } Why do you need the exra flag/test for IF-THEN-ELSEs? The simple answer is that you can't tie it the ELSE to either of the individual IFs or they'll end up triggering when they shouldn't (one IF is false, the other isn't) or they won't trigger when they should (the wrong IF is false.) An example: IF (A == true) { IF (B == true) { DoThis } ELSE { DoTheOther }} will only trigger DoTheOther whe B isn't true, not when A isn't true as you'd want an && to. IF (A == true) { IF (B == true) { DoThis }} ELSE { DoTheOther } will only trigger DoTheOther when A isn't true, not when B isn't true as you'd want an && to. IF (A == true) { DoThat } ELSE { DoTheOtherOther } IF (B == true) { DoThat } ELSE { DoTheOtherOther } will trigger DoTheOtherOther when either A or B aren't true, when we want it to trigger only if both A and B aren't true. An alternate to flagging for &&: IF (A == true) { IF (B == true) { DoThis } ELSE { DoTheOther}} ELSE { DoTheOther } still not as efficient as a && would be, but it, too, will work. (Please note that all of this is pseudo-code and would need to be massaged into several different chained objects to be used in an actual UI XML.) |
Just had a scary thought. It may be possible to create working WHILE loops using this technique. For instance:
<Button Name="Start" OnPress="Parent.Loop.Looping=true Parent.Loop.Press=true"></Button> <Button Name="Stop" OnPress="Parent.Loop.Looping=false"></Button> <Button Looping="false" Name="Loop" OnPress="DoStuff Press=Looping" Visible="false"></Button> FOR loops would work in a similar fashion, except it'd be something like: <Button Name="Start" OnPress="Parent.Loop.Looping=true Parent.Loop.Press=true"></Button> <Button Looping="false" Name="Loop" OnPress="DoStuff Looping=(TestArgument < TestCondition) Press=Looping" Visible="false"></Button> Oh, the implications of it all! |
If we can get while loops working, and if they cause no slowdown during an infinite loop, they could be used to cause active operations occur with the UI. Like a tooltip constantly updated with some odd data that we specify, or hotkey labels that are constantly kept updated rather than OnHoverIn/Out.
Quib |
Quote:
Why do I have the feeling we're about to bring every EQ2 server to is knees? Or maybe just the client machines. ;) |
So much for that theory. I just tried the following:
Code:
<Page AbsorbsInput="false" Location="8,62" Name="SpellsPage" OnShow="Loop.Press=true" ScrollExtent="570,367" Size="570,367"> |
Hehehe, oh well. I was hoping it wouldn't do a true loop and would only run the OnEvent once per frame.
Quib |
Quote:
You can't set a property to DynamicData. Here's how you'd do that: <Progressbar Name="Power" DynamicData="/Gamedata.Self.Power"... <Button OnPress="Parent.Trigger.Activated=(Parent.Power.Progress)>0.500"... <Button name="Trigger" OnActivate="laugh" OnDeActivate="cry"... Of course you'd actually have to have TWO triggers, one for activate, one for deactivate, because the OnActivate doesn't trigger if it's already activated, etc. But that's relatively minor. :D More brainstorming: Had someone request for a on-screen visual or sound when you are under attack. Best I could do was make it so when anything near you was attacked it brought up a window. Now we can have that window check to see if your health is less than 100%, and if it is, make trigger some flashing and noise. :D |
Quote:
|
Text comparisons work!
(fubar)==(fubar) returns true If parent.text='fubar' (parent.text)==(fubar) is true Simpler notation parent.text=='fubar' AND (test1)&(test2) returns true if both tests are true parent.text=='fubar'&1==1 is true parent.text=='fubar'&1==2 is false Bitwise &! and !& appear to do the same as &. OR and XOR | and || seam to result in the second test being ignored. Resturns value of the first test. Same for ^ |
All times are GMT -5. The time now is 01:56 AM. |
vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI