Gamevar operators: Difference between revisions
Jump to navigation
Jump to search
Hendricks266 (talk | contribs) No edit summary |
Hendricks266 (talk | contribs) No edit summary |
||
Line 16: | Line 16: | ||
|- | |- | ||
|set | |set | ||
|= | |<code>=</code> | ||
|= | |= | ||
|assignment | |assignment | ||
|- | |- | ||
|add | |add | ||
|<nowiki>+</nowiki> | |<code><nowiki>+</nowiki></code> | ||
|<nowiki>+</nowiki> | |<nowiki>+</nowiki> | ||
|addition | |addition | ||
Line 27: | Line 27: | ||
|- | |- | ||
|sub | |sub | ||
|<nowiki>-</nowiki> | |<code><nowiki>-</nowiki></code> | ||
|<nowiki>–</nowiki> | |<nowiki>–</nowiki> | ||
|subtraction | |subtraction | ||
Line 33: | Line 33: | ||
|- | |- | ||
|mul | |mul | ||
|* | |<code>*</code> | ||
|× | |× | ||
|multiplication | |multiplication | ||
Line 39: | Line 39: | ||
|- | |- | ||
|div | |div | ||
|/ | |<code>/</code> | ||
|÷ | |÷ | ||
|division | |division | ||
Line 45: | Line 45: | ||
|- | |- | ||
|mod | |mod | ||
|% | |<code>%</code> | ||
| | | | ||
|[[Wikipedia:Modulo operation|modulo]], remainder | |[[Wikipedia:Modulo operation|modulo]], remainder | ||
Line 51: | Line 51: | ||
|- | |- | ||
|and | |and | ||
|& | |<code>&</code> | ||
| | | | ||
|bitwise AND | |bitwise AND | ||
Line 57: | Line 57: | ||
|- | |- | ||
|or | |or | ||
|<nowiki>|</nowiki> | |<code><nowiki>|</nowiki></code> | ||
| | | | ||
|bitwise OR | |bitwise OR | ||
Line 63: | Line 63: | ||
|- | |- | ||
|xor | |xor | ||
|^ | |<code>^</code> | ||
| | | | ||
|bitwise XOR | |bitwise XOR |
Revision as of 14:51, 8 May 2011
<operator>var <gamevar> <value>
<operator>varvar <gamevar> <value>
Gamevar operators are commands that perform various mathematical operations on gamevars.
For example:
setvar temp 1 // assigns a value of 1 to the gamevar temp. addvar temp 1 // adds 1 to temp, causing its value to become 2. mulvar temp 2 // multiplies temp by 2, causing its value to become 4.
Operator | C/C++ | Math | Description | Notes | |
---|---|---|---|---|---|
set | =
|
= | assignment | ||
add | +
|
+ | addition | ||
sub | -
|
– | subtraction | ||
mul | *
|
× | multiplication | ||
div | /
|
÷ | division | Ensure that <value> does not equal 0 at any time. | |
mod | %
|
modulo, remainder | Ensure that <value> does not equal 0 at any time. | ||
and | &
|
bitwise AND | The bits in the result are set only if they were set in both of the values being operated on. | ||
or | |
|
bitwise OR | The bits in the result are set only if they were set in either of the values being operated on. | ||
xor | ^
|
bitwise XOR | The bits in the result are set if only one of the values being operated on has those bits set. |
Commands with an additional "var" suffix take gamevars rather than constants or defined labels for their inputs. As an alternate short form, "varvar" can be dropped from these commands; for example ife serves an an alias for ifvarvare.