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 computer 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 supplied on demand (at the cost of alternative ways to write expressions.)

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 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 a + is provided. So (1,2) becomes 0+(1,2) adding together 0 1 and 2 (and 1 becomes 0+1. Rules are rules.)

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

Sets proposal

Sets are a proposed feature. Implementation is to be delayed until deemed necessary.

A set here is not a set of number values. It is a multiset of named number and subscript pair references. If a plain number is added to a set it is said to be anonymous. The individual numbers of a set are accessed by ordinal with #el.

Sets and #subscripts are incompatible. In other words, el(A,1)[2] does not work (el(A[2],1) works; just to be 100% clear, but means something completely different which is besides the point.)

Where a set is operated upon like a number it is equivalent to the zeroth (0) reference in the set, and if that is itself a set, the zeroth reference of that set.

{:}

An empty set is written as {}. A two element set is written as {A,B} or {A B}. Here A is assigned original 0, and B is assigned ordinal 1. Ordinals can be skipped by writing {A,2:B}. He A is again assigned ordinal 0, and B is instead assigned ordinal 2. Ordinals must be positive whole numbers.

If A is itself a set then this must be acknowledged by writing {A} or {{A},B} or else A will be taken as the zeroth element of set A. This does not introduce an intermediary set. Too add an anonymous set write {{A,1,2},B} or {{{A},1,2},B} depending on whether A is to be a set or number reference.

el

el is undefined. el(A) yields A as a set. el(A,1) yields the ordinal 1 element of the set as a set. el(A,1,2) yields the ordinal 2 element of the ordinal 1 set of set A. Any other use yields a set.

no

no yields 0. no(A) yields the greatest ordinal of set A. no(A,1) yields the number of elements equal to the number 1 with respect to {{#_E}}. no(A,1,2) yields the number of elements between the range of 1 and 2. no(A,1,2,0) yields the number of elements between 1 and 2 with a precision of 0, or 0 is used in place of _E. no yields 0. no(A)-no(A,nan) yields the number of non-NaN elements in set A.

no(A,{B}) yields the number of elements of set A that are the named number B. no(A,{B,C}) is equivalent to no(A,{B})+no(A,{C}).