TeaScript Syntax
WIP documentation of TeaScript. Feel free to add any information necessary below.
Variables
To make a variable, open the variable menu by going to view -> Variable or ctrl+I. Then click 'Add' to make a variable. https://cdn.discordapp.com/attachments/273281168130965504/315971257713557504/unknown.png
Types of variables:
- Local Variable
- v(name) or val(name)
- str(name)
- Local Array
???
- Global Variable
- gv(name) or gval(name)
- gstr(name)
Expressions
Mathmatical Symbols
| Symbol | Name | Example |
|---|---|---|
| (+) | Addition | 3+2=5 |
| (-) | Subtraction | 3-2=1 |
| * | Multiplication | 3*2=6 |
| / | Division | 3/2=1.5 |
| \ | Division with no remainder | 3\2=1 |
| ^ | Power | 3^2=9 |
| & | Concatenation | 3&2=32 |
| () | Parentheses | (3+2)*6=30 |
| mod | Modulus | 3 mod 2 = 1 |
Functions
| Function | Desc | Example |
|---|---|---|
| abs() | Retuns the absolute value of a number. | abs(-3)=3 |
| exp() | Returns the power of e. | exp(5)=e^5 |
| log() | Returns the natural log. | log(e)=1 |
| sgn() | Returns the sign of a number. |
|
| int() | Rounds up. | int(2.1)=3 |
| fix() | Rounds down. | fix(2.9)=2 |
| sqr() | Returns the square root. | sqr(9)=3 |
| sin() | ||
| cos() | ||
| tan() | ||
| atn() |
Special numbers
- pi = 3.141592654
- e = 2.71828182
- rnd = A random value between 0 and 1.
Logical Expressions
Control Flow
If statements
if [conditon] then
'statement that should run if the first condition is true
elseif [condition] then
'statement that should run if the other condition is true
else
'statement that should run if all the other conditions are false
end if
Select Case
For Loop
Do Loop
There are three different versions of do loops: While loops, Until Loops, and Pure Loops.
'Pure loop:
do
'this loop will run infinitely until it hits an "exit do" statement
loop
'While Loop:
do while [condition]
'this loop will run as long as the condition returns true
loop while [condition]
'Until Loop:
do until [condition]
'this loop will run until the condition returns true
loop until [condition]
With while and until loops, you may choose where to place the 'while' or 'until' keyword. There can only be one of either keyword in the entire loop.
With Statements
Goto
Using goto it will force the script to jump to the specified line using a label.
Example:
[statements]
goto Example
When the script reached "goto Example" it will jump to "Example" and execute the script below it. The labels used with goto statements must: have names that do not contain characters that do not follow variable name rules and there must not be two labels with the same name.