Difference between revisions of "Set"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>JOG
m
imported>JOG
(added arithmetic operators)
Line 1: Line 1:
Sets a local or global variable to a specified value. This value can be a number or an expression.
Sets a local or global variable to a specified value. This value can be a number or an expression.


'''''Arithmetic Operators:'''''
{|border="1" cellpadding="5" cellspacing="0"
|-
! style="background:#efefef;" | Operator
! style="background:#efefef;" | Description
|-
|    <nowiki>+</nowiki>
| plus
|-
|    <nowiki>  -</nowiki>
| minus
|-
|    <nowiki>  *</nowiki>
| multiply
|-
|    <nowiki>  /</nowiki>
| divide (integer variables will be truncated)
|-
|    <nowiki>  %</nowiki>
| 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 a to 2
  set b to a*a
  set b to a*a

Revision as of 11:32, 17 April 2006

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".