![]() |
if then else and gamedata
Ok, say I wanted to check to see if a player was a Templar and if so make a page visible. Something like...
OnActivate="Visible=(GameData.Self.SubClass==Templar)" or something like: OnActivate="Visible=(Parent.Parent.Player.SubClass.Text==Templar)" Now first, can you use GameData in this fashion or do I need to use the Parent.* vars, if so where are the "Self" player fields. I looked in the default ui and couldn't find them myself. Can you use if, then, else statements? If so whats the proper format? If there is a FAQ on such things please feel free to point me to them, thanks! |
this thread may give you some insight on how things work. Scroll down a few posts and that should be what you’re looking for I think.
Would love to see some interfaces use some of this logic. |
Thanks for the link that definately cleared up some of the if then else questions I had. I followed the other thread as well and it does appear that GameData.* is not how you can compare values.
I am still kinda confused on that point but it seems I will use the Parent.* tree but unsure exactly how to find the "Self" values using it. Again thanks! |
Game Data is essentially a dynamic data link. A pipe that feeds data to other XML objects. Most of these DDs pass multiple attributes, so I doubt you'll be able to do comparisons on them directly.
The usual comparison method is to attach the desired DD to a standard XML object (like a text field) hidden off screen, then do your comparison against the LocalText of that object. |
Ok did some further testing. I created a Text object (PlayerClassName) in Player xml and the dynamicdata for the text is /GameData.Self.SubClass
I then have a page called "TemplarPage" underthat page are several options and images that are specific to templars. What I have done is this on that page: OnActivate="Visible=(PlayerClassName.LocalText=='Templar')" However it always displays the information under the TemplarPage no matter what class I login with. Does making the page, with objects below it, not visible not also make items within that page hidden? |
You would need to link it to the OnShow event of that window, as OnActivate won't get triggered.
|
Hiding a page does hide everything it contains.
You'll need a setup something like this... PalyerWindow |- PlayerClassName |- TemplarPage | `- Templar specific stuff |- General player stuff `- Window elements PlayerWindow has OnShow="TemplarPage.Activated=true" TemplarPage is initially Activated="false" and has the following script... OnActivate="Visible=(parent.PlayerClassName.LocalText=='Templar') Activated=false" Note: you must parent up befor referencing adjacent objects or the reference is interpreted as an attribute or child of the object containing the script. Also note its good prctice to reset the "Activated" to false on any objects that may need to have that script retriggered. If the object is already set to Activated=true, doing so again won't trigger the event. The same applies to almost every event attribute (Pressed is an exception, it automaticaly resets to false). Now the really tricky part of this is getting the PlayerWindow to trigger its OnShow event and at the right time. If the window is saved in a visible state, it may not fire untill the window visibility is toggled. There may also be timing issues where the OnShow fires before the PlayerClassName has been populated with DD. A workaround for this is to use Onshow and OnHide scripts to toggle the window off and on initially. Using this method your PlayerWindow would have the following scripts... OnShow="Visible=false" OnHide="OnShow='TemplarPage.Activated=true Visible=true" This insures the client is already in a state that allows toggeling window visibility (and DDs have been rendered) before activating the TemplarPage. The initial OnShow script cues up an event to hide the window. Once the client is able to do that, the OnHide script fires... changing the OnShow script to activate the TemplarPage, then shows the window. |
| All times are GMT -5. The time now is 11:01 AM. |
vBulletin® - Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
© MMOUI