number extensions

From Wiki

Jump to: navigation, search
m
Line 5: Line 5:
 
This section is available since [[SomEx|1.1.2.1]].  
 
This section is available since [[SomEx|1.1.2.1]].  
  
Extensions in this section take the form of "numbers" capital N (or Numbers) that can appear inside of the calculator like formulas accepted by [[#number]] extensions. Be wary that a few odd number-like extensions exist that are not in fact ''#numbers'' because an additional requirement for qualification (as of 1.1.2.1) is numbers must be able to be continuously reevaluated. If an extension is not up to the task then it is best to think of it as a strict numerical code or something else altogether.
+
Extensions in this section take the form of "numbers" capital N (or Numbers) that can appear inside of the calculator like formulas accepted by [[#number]] extensions. Be wary that a few odd number-like extensions exist that are not in fact ''#numbers'' because an additional qualification (as of 1.1.2.1) for numbers is the extension must be able to be continuously reevaluated. If it cannot it is best to think of it as a strict numerical code or something else altogether.
  
 
Numbers make the Ex.ini file programmable, and on the surface numbers can appear more powerful than Sword of Moonlight's native event system. For sure numbers are a more complete system, however the event system represents a true digital computer; whereas the easiest way to understand "numbers" is to picture a cheap old fashioned pocket calculator.
 
Numbers make the Ex.ini file programmable, and on the surface numbers can appear more powerful than Sword of Moonlight's native event system. For sure numbers are a more complete system, however the event system represents a true digital computer; whereas the easiest way to understand "numbers" is to picture a cheap old fashioned pocket calculator.

Revision as of 05:57, 23 May 2013


This section is available since 1.1.2.1.

Extensions in this section take the form of "numbers" capital N (or Numbers) that can appear inside of the calculator like formulas accepted by #number extensions. Be wary that a few odd number-like extensions exist that are not in fact #numbers because an additional qualification (as of 1.1.2.1) for numbers is the extension must be able to be continuously reevaluated. If it cannot it is best to think of it as a strict numerical code or something else altogether.

Numbers make the Ex.ini file programmable, and on the surface numbers can appear more powerful than Sword of Moonlight's native event system. For sure numbers are a more complete system, however the event system represents a true digital computer; whereas the easiest way to understand "numbers" is to picture a cheap old fashioned pocket calculator.

  • Extension assignment

When assigning an expression to a Number in the #Number (or this) section there are between one-and-three parts to the left of the equal (=) sign and either an expression or a label to the right. When assigning to a regular number extension in any other section the expression part is the same except that the expression cannot refer to the number being assigned to (as a number is not a Number)

When assigning a Number to itself, or referring to that number in the assigned expression, the Number is actually duplicated and kept as a backup, appearing only within the assigned expression. Wherever else the Number appears its current assignment is given priority.

The three parts to the left of the equal sign take the form of name_0_label. Where name is name of the Number as it appears in expressions. And _0 is a zero-based positive integer owing to the fact that each Number is truly a collection of parts, or a battery of numerical expressions, each defaulting to NaN or "not-a-number". If _0 is absent then 0 is assumed and _label cannot be present as it would run into name. After the underscore (_) in _label anything may appear up to 30 Unicode characters to be used as a label for that part. In other words Sword of Moonlight's "counters" labels and all can fit into a single Number in battery form.

For readability it is recommended that _label not include spaces. However there is an alternative was of assigning a label where only the underscore (_) part of _label appears and the label itself is written to the right of the equal (=) sign. This approach can also aid readability by keeping the equal signs lined up one above the next.

So that each number potentially has many parts. Each part can be accessed with a square bracket ([]) notation. For example x[1] for the second part of x. Or if x[1] is labeled, x[x[1]'s label], though you must be careful with [ and ] inside of labels so that they always appear in nested pairs so not to be confused with the end of the label.

Functions hold default parameters and labels in the parts just above them. So f[1] holds the default parameter for the first argument of the function f (refer to the system number _ below for input parameters access within a function)

  • Mathematical symbols

In addition to the familiar plus (+) minus (-) multiplication (*) and division (/) operators (using standard infix association) there are exponent (^) for squared, cubed, etc. and complex square and Nth root by way of fractional "powers" and grouping parentheses (()) following algebraic order of operations and absolute value (||) vertical bars.

Numbers can be prefixed by minus (-) to be made negative or plus (+) to note as positive. Note that + can actually be useful inside of square brackets ([]) to distinguish between numbers and labels. Also care must be taken to ensure that numbers are not interpreted as a series or sequence. To do so operators must be surrounded by spaces on both sides or appear direction in front of a number or appear between numbers without any extra space.

Functions make use of z = f(x,y) notation, read f of x and y yields z, where f is the name of the Number and x and y are parameters of its function.

  • Branching symbols

So called ternary if-then-else, or otherwise, functionality is achieved by the x?y:z pattern where x is the predicate, and y is number chosen if x is nonzero, and z is the number chosen if x is zero (refer to _E below for the definition of zero)

  • Built in functions

Logical functions include and(...,n) nand(...,n) or(...,n) nor(...,n) xor(x,y) xnor(x,y) and not(x[,y]) where the second parameter of not is optional. If present y is subtracted from x.

Inequality functions include neg(x[,y]) where y like above is optional and subtracted from x. If x is less than zero (0) neg is one (1) or else zero. In other words neg is one if x is negative. If not zero. Neg is not-equal-nor-greater. Be wary that complex numbers are never negative according to neg.

Identity functions include nan([x]) and inf([x]) where both are one (1) if x is NaN, or not-a-number, or infinity (∞) respectively. Zero (0) alternatively. The parameter x is optional. If omitted the parentheses should be omitted also. Instead of one and zero the functions yield the literal numbers NaN (not really a number but a value nonetheless) and infinity.

Utility functions include int(x) discarding the fractional part of a number, and mod(x,y) yielding the remainder of x divided by y.

Complex functions include x(x) and y(x) and iy(x) where x yields the "real" part of a number, y the "imaginary" part of a number as a "real number", or a number that is not complex, and iy the "imaginary" part of a number as a complex number, or a "purely imaginary" number.

Supplemental functions include pow(x,y) abs(x) and if(x,y,z) where pow is equivalent to x^y and abs is equivalent to |x| and if is equivalent to x?y?z.

Additional functions include exp(x) and log(x[,y]) where y is base-e (2.71828) if omitted. And all of the standard trigonometric functions, sin(x) cos(x) and so forth (a complete list is forthcoming.)

  • Built in numbers

The numbers pc and npc hold stats for the player character and non player character respectively. Note that these may change (and be unavailable) in any given context. And c holds the values of the game's "counters". Bear in mind that number expressions cannot change these values but the values themselves are subject to change.

The number r generates random positive integers between 0 and one less than the integer ID accessed. So that r[2] can be 0 or 1. r[0] or simply r makes use of the widest range possible.

  • System numbers

_ always refers to the parameters of a function. _[0] holds the number itself. Note that technically all numbers are functions of themselves. _[1] holds the first parameter, _[2] the second, and so on. Note that _[0] or simply _ is off limits outside of the #Number section (until further notice.)

_E, or Epsilon, is a fractional number so small to only be meaningful as rounding error. If the absolute value of a number is less than _E then it is considered to be zero (0) when comparing for equality.

_WALK, _DASH, _TURN refer to the system speed settings defined by the game's Sys.dat file.

  • Shorthand notation

Inside of expressions the number c[2] can be written 2c. However c[intro] and c[1+2] won't work. One becomes introc (another number altogether) and 1+2c, or c[2]+1 (unless that was what you wanted.)