|
acaykath Wanderer
Joined: 03 Aug 2005 Posts: 84
|
Posted: Sun Apr 29, 2012 2:57 am
Toggle Buttons not Toggling |
I want to make a set of toggle buttons for my automatic actions. I have scripts for various things such as gold running which is located in the class "GoldrunTerra".
I have created a button and set:
Code: |
Main Button:
Caption: Gold Run
Type: Toggle
Language: zScript
Script Text: #T+ GoldrunTerra
Expr: %trigger(GoldrunTerra)=1
Tooltip: Toggle Gold Running
1:
Caption: Stop Gold Running
Language: zScript
Script Text: #T- GoldrunTerra
|
Whether I click the button or toggle the state of "GoldrunTerra" manually, the state of the button does not change. Any idea wheat I am doing wrong? |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Sun Apr 29, 2012 3:13 am |
I usually make such things a simple push button
#IF (%trigger(GoldrunTerra)) {#T- GoldrunTerra} {#T+ GoldrunTerra} |
|
_________________ Discord: Shalimarwildcat |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sun Apr 29, 2012 3:44 am |
The expression field sets the button state, so essentially you're forcing the toggle state to remain in/revert to the upright position. Maybe remove the =1 part, but it's probably easier to do as Shalimar does and simply include a visual indicator (ie, button image or caption change).
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
acaykath Wanderer
Joined: 03 Aug 2005 Posts: 84
|
Posted: Sun Apr 29, 2012 3:12 pm |
I don't mind doing it programatically but I have no idea how to change the caption of an already created button and I'd like to have the visual indication that it is on or off.
Without the =1, it just remains stuck in the off state instead of the on state, even though I've tested the expression and it gives 0 when off and 1 when on. |
|
|
|
|
|