Difference between revisions of "Set"
Jump to navigation
Jump to search
imported>JOG m |
imported>JOG m (clarifications about using "-" as operator or sign) |
||
Line 3: | Line 3: | ||
set a to 2 | set a to 2 | ||
set b to a*a | set b to a*a | ||
set c to (b-a)*b-a | set c to (b - a)*b - a | ||
set d to (3*-b+a)-c)/-2 | set d to ((3* -b+a) - c)/ -2 | ||
message "a=%.0f, b=%.0f, c=%.0f, d=%.0f" a b c d ; ("a=2, b=4, c=6, d=8") | |||
set stage to getstage quest1 + 10 | set stage to getstage quest1 + 10 | ||
As you see, when you put a minus right in front of a variable it will be negated. To acomplish this, the parser needs you to put spaces arount all minuses that are actually operators instead of signs. If you use "a-b" in the above example, the script doesn't compile; it needs to be "a - b". | |||
[[Category:Commands]] | [[Category:Commands]] |
Revision as of 02:45, 17 April 2006
Sets a local or global variable to a specified value. This value can be a number or an expression.
set a to 2 set b to a*a set c to (b - a)*b - a set d to ((3* -b+a) - c)/ -2 message "a=%.0f, b=%.0f, c=%.0f, d=%.0f" a b c d ; ("a=2, b=4, c=6, d=8") set stage to getstage quest1 + 10
As you see, when you put a minus right in front of a variable it will be negated. To acomplish this, the parser needs you to put spaces arount all minuses that are actually operators instead of signs. If you use "a-b" in the above example, the script doesn't compile; it needs to be "a - b".