|
miegorengman Wanderer
Joined: 05 Sep 2008 Posts: 53
|
Posted: Wed Jun 08, 2022 6:34 pm
getting my syntax right |
i have many buttons that share variables with aliases and triggers. for these i avoid using toggle buttons as the variable will refresh but not the toggle state, forcing me to click cmud toggles twice to change the state. my homemade toggles look something like this.
Code: |
#if (@activitiesonoff < 100) {
#t- activities
#VAR showonoff {inactive}
#variable activitiesonoff {101}
} {
#t+ activities
#var showonoff {ACTIVE}
#variable activitiesonoff {99}
}
|
this setup has 2 separate variables, one string to display the state and one integer allowing the if to change the state.
some years later i think i have learned more, so i decide to use a single string variable....just the string, but no worky
i have a button captioned: autoSC with the
with script text: #if (@autosc = "on"){#var autosc {off}}{#var autosc {on}}
or
Code: |
<button autosize="false" width="87" height="16" color="black" textcolor="#339966" priority="34610" id="3461">
<caption>autoSC @autosc</caption>
<value>#if (@autosc = "on"){#var autosc {off}}{#var autosc {on}}</value>
</button> |
[code]
I have referred to the CMUD Manual and a comparable example is: [code]#IF (@line =~ "You receive (%d) coins") {split %pat(1)}[/code]
and I have tried a number of variations but as far as I can tell my syntax within the first set of brackets is wrong...but I can't tell how.
I have tried the following variations and more:
(@autosc =~ "on")
(@autosc = {"on"})
(@autosc = {on})
(@autosc = ("on"))
(@autosc = on)
(@autosc =~ "on")
(@autosc = "on")
if anyone has any suggestions that would be wonderful. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Wed Jun 08, 2022 7:27 pm |
Your issue seems to be one of spacing. Or rather, its lack.
Try:
#if (@autosc = "on") {#var autosc {off}} {#var autosc {on}} |
|
_________________ Discord: Shalimarwildcat |
|
|
|
miegorengman Wanderer
Joined: 05 Sep 2008 Posts: 53
|
Posted: Wed Jun 08, 2022 10:19 pm |
thank you for the quick response and thank you for the detail :)
|
|
|
|
chris123zugg Apprentice
Joined: 23 Aug 2013 Posts: 175
|
Posted: Tue Jul 12, 2022 12:49 pm |
(@autosc =~ "on")
(@autosc = {"on"})
(@autosc = {on})
(@autosc = ("on"))
(@autosc = on)
(@autosc =~ "on")
(@autosc = "on")
i always use #IF (@autosc=="on") {dostuff] {elsedostuff}
autosac=on defines the variable to on...therefore when youre attempting to ask cmud to look to check that variables state it is sending its this, but it cant define in an if so does nothing.
autosac==on will work as well, but ive had issues before with it not recognizing the definition so i enclosed in "'s to make it abolute check for "on"
when dealing with numerals you will have use of other forms of variable definitions or checks as well...
autosac =~"on" will make it look for anything with "on" on the variable .. so it could have on the mountain and "on" will still work, but not the way you want. |
|
|
|
chaossdragon Apprentice
Joined: 09 Apr 2008 Posts: 168
|
Posted: Tue Jul 12, 2022 10:24 pm |
for on/off states I tend to use boolean (if that is the correct term) 1/0 so (@autosc = 1) {on} {off}
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Wed Jul 13, 2022 2:41 pm |
I take the boolean method one step further and do a test for any non null value, and since 0 is equivilent to null...:
#IF (@autosc) {autosc=0} {autosc=1} |
|
_________________ Discord: Shalimarwildcat |
|
|
|
|
|