- Return to Touhou Danmakufu: Syntax
Values[]
Numbers[]
0 345 12.34 0.12345
Normal real numbers.
Boolean values[]
true false
True or false as value. In numerical expressions such as true + 1 and false x 5 - 2, true and false are taken as 1 and 0 respectively. However, as of v0.12m of Danmakufu, they cannot be compared with other numerical expressions, e.g. conditionals like true == 1 and false > 0 will not parse.
Characters[]
'A' 'E' 'あ'
One letter. Japanese character can be used.
Arrays[]
[3, 1, 4, 1, 5, 9] [true, false, true, true, false]
Array of values. Multidimensional arrays can be used, e.g.
let Array = [ [3, 1, 4], [1, 5, 9] ];
the entry Array[1][2] will then have the value 9. To change the value of Array[1][2], v0.12m of Danmakufu will not parse
Array[1][2] = 8; //this is wrong
One way to do this is
Array[1] = [1, 5, 8]; //this is correct
i.e. you can only change entries that are one level deep. 'Mixed-entry' arrays are not allowed, e.g.
Array = [ [3, 1, 4], [1, 5] ]; //these are wrong Array2 = [ [3, 1, 4], 1 ];
will not parse. The entries in an array must all be of the same kind.
You can concantenate arrays
[3, 1, 4] ~ [1, 5, 9];
this gives the single array
[3, 1, 4, 1, 5, 9]
You can also erase entries from arrays
erase([3, 1, 4, 1, 5, 9], 2);
this gives the shortened array
[3, 1, 1, 5, 9]
Strings[]
"Hello, world!" "Test Sign 'Test'" "試符「テスト」"
Arrays of characters.
\"
describes a string literal which contains only a letter ".
Variable Definitions[]
let ImgBoss = "script\img\ExRumia.png"; let frame = -120; let array = [3, 1, 4, 1, 5, 9];
Variables are storages of values. let is used to define variables.
let (variable name); let (variable name) = (initial value);
The variable name consists of alphabets, figures, and underscore (_), but it cannot begin with figures. The initialization of the variable can be omitted.
Expressions[]
Numerical Expressions[]
6 * 2 + (4 - 3) * 9 x ^ 2 + 3 % x + 8
Standard numerical expressions. The priority of operators is common-sense. Variables can be used in the expressions.
Conditional Expressions[]
frame == 10 ! (x < y && y < z)
Standard conditional expressions. The results of the conditional expressions are boolean values. Note that "if equal" is not '=' but '=='. For the meanings of the operators, refer to the Priority of Operators subsection.
Indexing Expressions[]
[3, 1, 4, 1, 5, 9][2] array[i]
Get an element of the array with the index.
array[1..4]
A slice of the array can be extracted.
(array)[(index)] (array)[(first index)..(last index)]
Array Calculations[]
[3, 1, 4] + [1, 5, 9] array1 + array2
Each element is calculated, e.g. [3, 1, 4] + [1, 5, 9] is [4, 6, 13].
String Expressions[]
"script\img\ExRumia.png" ImgFolder ~ "ExRumia.png"
Operator '~' concatenates two arrays (of course strings, too). String leterals can be concatenated without ~ operators as
"Wave Sign " \" "Mind Shaker" \"
which is such a string as
Wave Sign "Mind Shaker"
Priority of Operators[]
High Priority
( )
Parentheses(| |)
Absolute value[ ]
Indexing, Slicing^
Power+
Plus sign-
Minus sign!
Conditional not*
Multiplication/
Division%
Modulo (Remainder)+
Addition-
Subtraction~
Concatenation==
Equal to!=
Not equal to<
Less than<=
Less than or equal to>
Greater than>=
Greater than or equal to&&
Conditional and||
Conditional or
Low Priority
Assignment Statements[]
Simple Assignment Statements[]
y = x ^ 2 + 3 * x + 8; frame = 0; array[2] = 4;
Change the left-side variable contents with right value.
(variable) = (expression);
Compound Assignment Statements[]
x += 3; y *= 2;
Operate right value to the left-hand variable and assign the result into the variable. e.g.
x += 3;
adds 3 to x, and
y *= 2;
multiplies 2 to y.
(variable) (binary numerical operator)= (expression);
Increment/Decrement[]
frame++;
Add 1 to the variable.
i--;
Subtract 1 from the variable.
- Return to Touhou Danmakufu: Syntax