7HS (Message Wall | contribs) m (cat) |
|||
Line 19: | Line 19: | ||
false |
false |
||
− | True or false as value. In numerical expressions, '''true''' and '''false''' are taken as 1 and 0 |
+ | 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 === |
=== Characters === |
Revision as of 06:39, 26 July 2007
- 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.
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 gotton.
(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