Posted by member 212670 on 2006-01-11 20:55:52 link
Basic toggle script:
The same thing again, but setup differently:
Both are called with "!toggle yourvarhere" like: !toggle amp
If you don't want to use arguments, you can just use !toggle, but you have to change the %{\1} entries in the evaluation parts to an exact var, like "%{amp}". The !varset parts would just be amp (no "%{}").
If you have a series of things to do, I prefer the gotoif setup.
(Note: This is for mzscript-0.9.13. If you're using mzscript-1.0-rc2, the syntax is slightly different, but same idea.)
*Script bang !toggle
*Script exec !IfEval ("%{\1}" = "1") '!do_something_if_1' else '!do_something_if_0'
*Script exec !IfEval ("%{\1}" = "1") '!varset %{\1} 0' else '!varset %{\1} 1'
*Script ~bang
*Script exec !IfEval ("%{\1}" = "1") '!do_something_if_1' else '!do_something_if_0'
*Script exec !IfEval ("%{\1}" = "1") '!varset %{\1} 0' else '!varset %{\1} 1'
*Script ~bang
The same thing again, but setup differently:
*Script bang !toggle
*Script gotoif ("%{\1}" = "1") off
*Script exec !do_something_if_0
*Script exec !varset %{\1} 1
*Script exit
*Script label off
*Script exec !do_something_if_1
*Script exec !varset %{\1} 0
*Script ~bang
*Script gotoif ("%{\1}" = "1") off
*Script exec !do_something_if_0
*Script exec !varset %{\1} 1
*Script exit
*Script label off
*Script exec !do_something_if_1
*Script exec !varset %{\1} 0
*Script ~bang
Both are called with "!toggle yourvarhere" like: !toggle amp
If you don't want to use arguments, you can just use !toggle, but you have to change the %{\1} entries in the evaluation parts to an exact var, like "%{amp}". The !varset parts would just be amp (no "%{}").
If you have a series of things to do, I prefer the gotoif setup.
(Note: This is for mzscript-0.9.13. If you're using mzscript-1.0-rc2, the syntax is slightly different, but same idea.)