list of numbers

From Wiki

Jump to: navigation, search

Numbers are a means to add some programmatic functionality to Sword of Moonlight via calculator like mathematical expressions. Numbers are typically setup inside of an Ex.ini file. This list contains built in and so-called system numbers only.

Sword of Moonlight

Variables

c

pc

npc

Constants

List of

Legend
SOM_SYS settings part of SOM_SYS (SOM_SYS.exe) usually kept in the Sys.dat file.
m/s the constants units are meters per second.
c/s the constants units are radians per second.
Note that constants based on figures originally in degrees are converted to radians.
_WALK (SOM_SYS; m/s)
the player character walking speed.
_DASH (SOM_SYS; m/s)
the player character dashing speed.
_TURN (SOM_SYS; c/s)
the player character turning speed.

Serialization

It is possible to write a series of numbers. Care must be taken to not do so accidentally. The following table demonstrates the rules that must be observed. However the basic rules are pretty simple. If a mathematical operator has a space on one side, then it must have a space on its other side, and vice versa. In other words, 1 + 2 or 1+2. If a positive (+) or negative (-) sign appears in front of a number it must be flush with the number, or -1, not - 1. There are no operators that appear behind numbers.

input produces output
1 2 => 1, 2
2 +3 => 2, 3
3 + 4 => 3+4
4 + -5 => 4-5
input produces output
5 +-6 => 5, -6
-6+7 => -6+7
-7--8 => -7+8
-8 --9 => -8, 9


If you experience different results then that is a software bug that should not be relied upon in order to ensure you expressions continue to work correctly in the future.

Tip: where there is no empty space an expression cannot be interpreted as a series. 2(X) is 2*X, (X)(Y) is X*Y, and Y(2)X is X[Y(2)] and 2XY is XY[2]. This all works because plain numbers when written as a function behave as if multiplied. The rest is explained by #subscripts.

Space and separators

Spacing characters include space ( ), tab, carriage-return, new-line, and any other character that produces empty space wherever it appears. Note that tab and other kinds of characters sometimes appear as zero width spaces. This can be a nuisance as they will nonetheless be interpreted as space.

End of the line characters (carriage-return and new-line) are ignored along with any spacing characters that follow. When working with multiple lines care must be taken to observe spacing rules precisely. When a series is spread over multiple lines an explicit separator (#,;) should be placed between the last element on the line and the first element on the next line. A semicolon (;) at the end of the line is recommended for this.

Like with HTML (except for following the end of a line where empty space is ignored) one space, or two spaces, or any number of spacing characters (and or separators) is collapsed into a single space for purposes of serialization.

,;

The colon (,) and semicolon (;) are reserved separators. They are strictly equivalent to a space ( ) character, except you can see them as written. In other words 1 2 or 1,2 or 1;2 it doesn't matter. If necessary more separators can be added or an extension can be provided to allow for the definition of custom separators.

Note that separators are simply filtered out. So if you write 1,+,2 this is equivalent to 1+2. Care should still be taken to observe the rules of serialization and cautions about working with multiple lines in the previous section.

Subscripts and labels

[]

Mathematics

With math it is possible to write a number as a mathematical expression with 0 or more input parameters. Refer to #_.

Grouping semantics allow expressions to contain subexpressions. Series within a subexpression are interpreted as input parameters. Refer to #() and #||.

An expression is made up of numerical terms held together by mathematical operators. A term can be a single number or a group of numbers. Operators resemble punctuation. For example: 1+2 includes two terms, 1 and 2, and one operator, +, or plus.

This distinction is stressed because each expression is a kind of program where each character in the program must be strictly interpreted. There is no tolerance for error, and in 9 out of 10 cases no red flags to be raised in case of error. Intolerance is a feature of all programming languages, and is nonnegotiable. Red flags on the other hand, can be added (if so desired) at the cost of restricting the ways in which an expression can be expressed.

Numbers directly adjacent to (but not inside of) parentheses become a function of the inner terms of the parentheses, or the function's input parameters. Plain numbers, such as 1 or 1.5, share a built in function; multiplication. Other numbers can only be written with the parentheses on their right. Refer to #() (when written on the left the result is a #subscript; not a function at all.)

While operators technically are functions, they are not usually written as such. However it is possible to do so. For example, 1+(2,3) adds together 1, 2, and 3.

Wherever a term should logically appear but is omitted a zero (0) is provided. For instance. Operators always have a left term and a right term. And groups are not allowed to be empty. Consider -1+2. Which becomes (0-1)+2. Note that it does not become 0-1+2. The distinction can sometimes make a difference. Though less common, the same rule applies on the right: 1- becomes 1-0. Here parentheses are not needed. And last but not least: () becomes 0 (so consider that f() becomes f(0) where f is some mathematical function.)

Likewise terms and operators must always appear together. If an operator is omitted then + is assumed. So (1,2) becomes +(1,2) adding together 1 and 2.

Calculations

Arithmetic

()

||

Enclosing an expression within two vertical bars (|) yields its absolute value. For example, |-7| makes 7. But you must beware that nesting without parentheses (#()) is not supported. Something like |c[|A|]| also works where square brackets are able to be used in place of parentheses.

In other words: |(|A|-|B|)| does work. While ||A|-|B|| does not work. Alternatively consider #abs(|A|-|B|).

abs

Decision trees

?:

if

Logical operations

_E

and

nand

or

nor

xor

xnor

Complex numbers

x

y

iy

Identity coalescence and inequality

nan

inf

not

neg

Reflection and recursion

_

_S

_$

_N

Statistical analysis

n

int

mod

min

max

r

Transcendental functions

^

cos

exp

log

pow

sin

tan