18,700
edits
Script 10k (talk | contribs) (wow reading oni memory from bsl, undefined behavior at its best? Probably this should be patched.) |
(→Arithmetical: copy edit) |
||
Line 335: | Line 335: | ||
===Arithmetical=== | ===Arithmetical=== | ||
These operations do not change the numbers that the operators act upon; they merely provide a resulting number for your use. | These operations do not change the numbers that the operators act upon; they merely provide a resulting number for your use. Note that there is no operator for multiplication or division. Bungie West was only concerned with creating enough scripting power to drive Oni, and they did not need "higher math" for this. See [[#Data types|Data types]] to learn the details of how math works between different data types. | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 351: | Line 351: | ||
|} | |} | ||
A quirk of the subtraction operator is that it is sensitive to whitespace. For instance, the following code will print "NOT -1": | |||
if(5-6 eq -1){ | if (5-6 eq -1) | ||
{ | |||
dmsg("-1"); | dmsg("-1"); | ||
} | } | ||
else{ | else | ||
dmsg("NOT -1"); | { | ||
dmsg("NOT -1"); # this code will run | |||
} | } | ||
In order for the operator "-" to work correctly, you need to have a space between it and the numbers being subtracted, otherwise it may return unexpected results! So to fix the code above, you should write it like this: | |||
So to fix the code above you should write it like this: | |||
if(5 - 6 eq -1){ | if (5 - 6 eq -1) | ||
dmsg("-1"); | { | ||
dmsg("-1"); # this code will run | |||
} | } | ||
else{ | else | ||
{ | |||
dmsg("NOT -1"); | dmsg("NOT -1"); | ||
} | } | ||
Alternatively, you can use the sum operator, which doesn't suffer from this issue: | |||
if (5+-6 eq -1) | |||
{ | |||
if(5+-6 eq -1){ | dmsg("-1"); # this code will run | ||
dmsg("-1"); | |||
} | } | ||
else{ | else | ||
{ | |||
dmsg("NOT -1"); | dmsg("NOT -1"); | ||
} | } | ||
===Relational=== | ===Relational=== |