Set

From the Oblivion ConstructionSet Wiki
Revision as of 11:32, 17 April 2006 by imported>JOG (added arithmetic operators)
Jump to navigation Jump to search

Sets a local or global variable to a specified value. This value can be a number or an expression.


Arithmetic Operators:

Operator Description
+ plus
- minus
* multiply
/ divide (integer variables will be truncated)
 % modulus (do integer division and return remainder)


In integer divisions the remainder is truncated at the end of the operation:

set a to 9/5 will set a to 1

set a to 10*9/5 will set a to 18


Examples:

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 the variable will be negated. To acomplish this, the parser needs you to put spaces around all minuses that are operators and not algebraic signs. If you use "b-a" in the above example, the script doesn't compile; it needs to be "b - a".