|
wrym Magician
Joined: 06 Jul 2007 Posts: 349 Location: The big palace, My own lil world
|
Posted: Thu May 21, 2009 5:10 am
Button varibles/expressions |
The new button code has cause me to rework/re-think a number of my current scripts.
Currently I have a number of scripts, menus, status window items that have captions like:
Code: |
@en_dis_able(//combat/combat/turn_rescue) Turn Rescues |
(@en_dis_able is a function that returns "Enabled" or "Disabled" depending if it's enabled or disabled.)
Which I want to turn into a 2 color button/toggle/gauge.
Most of these are enabling triggers, classes, and events, and for most applications this is easy enough to accomplish.
However I have a few where the button will not be the only setting enabling and disabling them, making it possible for
the setting, and the button to become un-synchronized.
Now for where i'm stuck. I have tried using %trigger/%class in the variable field and several different combinations in the expression field,
No combinations have fully worked. What does work, is an extra variable with "%trigger(<setting name>)" as a value. A function with "%trigger(%1)" does not work.
Now..Am I missing a really easy way to do this? If not,...
How come the settings enable/disable action only correctly sets the variable which sets the button, and not directly sets the button?
Is this a bug? If not, would it be possible to use functions, like %trigger() as the value for toggle button?
And yes, I do realize that trying avoid that extra variable for each button, is like trying to cut weight with a haircut.
Thanks in advance for any thoughts/input. |
|
_________________ "To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu May 21, 2009 5:17 am |
It depends on what "//combat/combat/turn_rescue" is supposed to reference. I'm going to assume that it's a variable, but that's not clear from the snippet you posted.
It seems to me that the easiest way to handle this is with two button states of different colours. State 0 is the disabled state, with caption and colour to match, and state 1 is the enabled field. You use the @//combat/combat/turn_rescue variable in the Expr box of the button, and then changing the variable to 0 or 1 will change the state as well. And that's all you need to do. |
|
|
|
wrym Magician
Joined: 06 Jul 2007 Posts: 349 Location: The big palace, My own lil world
|
Posted: Thu May 21, 2009 5:19 am |
Sorry, in this case "//combat/combat/turn_rescue" is a trigger. Sadly very few... quite possibly none, of these are actually variables I can set to 1 or 0.
|
|
_________________ "To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu May 21, 2009 7:22 am |
You can use any expression, though - so you can use the %trigger or %class functions in the Expr box just as easily as a variable. In fact, if your @en_dis_able function returned 1 or 0, you could use that in there. I get the impression that it's basically a wrapper for %trigger, but you get the idea :P
|
|
|
|
wrym Magician
Joined: 06 Jul 2007 Posts: 349 Location: The big palace, My own lil world
|
Posted: Thu May 21, 2009 4:14 pm |
I tried using an expression, but button was forced to a certain state and held there... which I guess makes sense...
Introduction to Buttons wrote: |
The Value field is similar to the Variable field, but specifies a full expression used to determine the state of the button. For example, the expression "@Name = "Zugg"" can be used. The button will be pressed in whenever the variable @Name has the value of "Zugg". Clicking the button will have no effect...the button is now controlled by this expression value. |
So... looks like i'm stuck with using that variable with a value of "%trigger(<setting name>)"
and yeah @en_dis_able just wrapper returning a text value of %trigger. |
|
_________________ "To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu May 21, 2009 4:20 pm |
Thinking about it, yes, you'll need some variable in there to force a check of the expression, the same way you'd need to in a status object. I've posted more details about doing that in the past.
|
|
|
|
wrym Magician
Joined: 06 Jul 2007 Posts: 349 Location: The big palace, My own lil world
|
Posted: Thu May 21, 2009 4:41 pm |
Mkay, I've a few of them working atm. Was checking/hoping for another/simpler solution.
Thanks for input. |
|
_________________ "To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle |
|
|
|
|
|