Updated Scripting (markdown)

suchmememanyskill 2020-02-07 00:55:16 +01:00
parent 5b5a872ecd
commit c71633745c

@ -5,7 +5,7 @@ The extention of them are .tegrascript, and they are normal text files.
- \<COMMAND\> executes a command
- "ARG" is an argument to a command
- {} is for "if statements" (will be explained later)
- $FLAG$ is for "if statements" (will be explained later). There's $TRUE$ and $FALSE$. $ERROR$ is an alias for $TRUE$ and $NOERROR$ is an alias for $FALSE$
- $FLAG$ is for "if statements" (will be explained later).
## Commands
@ -21,11 +21,23 @@ The extention of them are .tegrascript, and they are normal text files.
| \<EXIT\> | Exits the script instantly |
| \<PAUSE\> | Pauses the script until a button is pressed. returns $TRUE$ if the power button is pressed, and $FALSE$ if the volume buttons are pressed |
## Flags
Flags are basically checks, written as $FLAG$. See below for how to use them
| Flag | Use |
|:----:|:---:|
| $ERROR$, $TRUE$ | Based on the last command run, if the last command errored out, this check will be True |
| $NOERROR$, $FALSE$ | Based on the last command run, if the last command didn't error out, this check will be True |
| $BTN_POWER$ | Based on the last \<PAUSE\> output. If the power button was pressed, this will return True |
| $BTN_VOL+$ | Based on the last \<PAUSE\> output. If the volume up button was pressed, this will return True |
| $BTN_VOL-$ | Based on the last \<PAUSE\> output. If the volume down button was pressed, this will return True |
## Flow control
There's a sort of implementation of an else-if statement. If you run a $FLAG$ it will set an internal flag for what it should do next. if True, it will jump to the next `{` (after it exits the `{}` the flag is set to false again), if False, it will ignore everything between any `{}` it comes across (unless obviously the flag is set to true again). Example:
- Example1:
- Example 1:
```
<COPY> "sd:/file1" "sd:/file2"
@ -36,7 +48,7 @@ $ERROR$ {
}
<PAUSE>
```
- Example2:
- Example 2:
```
<COPY> "sd:/file1" "sd:/file2"
@ -64,3 +76,23 @@ $NOERROR$
<PAUSE>
```
- Example 3
```
<PRINT> "Press a button"
<PRINT> ""
<PAUSE>
$BTN_POWER$ {
<PRINT> "You pressed the power button!"
}
$BTN_VOL+$ {
<PRINT> "You pressed the vol+ button!"
}
$BTN_VOL-$ {
<PRINT> "You pressed the vol- button!"
}
<PAUSE>
```