Add note about main function requirement and function calls
This commit is contained in:
parent
714aacf1ca
commit
f43693ec19
|
@ -44,6 +44,10 @@ fn main() {
|
||||||
```
|
```
|
||||||
This code defines a function called `main` that will be executed every tick.
|
This code defines a function called `main` that will be executed every tick.
|
||||||
|
|
||||||
|
:::note
|
||||||
|
ShulkerScript always requires a `main` function to be present in the code.
|
||||||
|
:::
|
||||||
|
|
||||||
### Annotations
|
### Annotations
|
||||||
Annotations are special attributes that can be attached to functions.
|
Annotations are special attributes that can be attached to functions.
|
||||||
They start with `#` followed by the name of the annotation in square brackets. Some annotations can have arguments assigned to them with the `=` operator.
|
They start with `#` followed by the name of the annotation in square brackets. Some annotations can have arguments assigned to them with the `=` operator.
|
||||||
|
@ -54,6 +58,19 @@ Currently the following annotations are supported:
|
||||||
- `#[deobfuscate]`: The function will keep the original name in the output (path of the `.shu`-file followed by the function name).
|
- `#[deobfuscate]`: The function will keep the original name in the output (path of the `.shu`-file followed by the function name).
|
||||||
- `#[deobfuscate = "path/to/function"]`: The function will be named as specified in the argument.
|
- `#[deobfuscate = "path/to/function"]`: The function will be named as specified in the argument.
|
||||||
|
|
||||||
|
### Function calls
|
||||||
|
Functions can be called by using their name followed by parenthesis.
|
||||||
|
```shulkerscript
|
||||||
|
#[tick]
|
||||||
|
fn main() {
|
||||||
|
hello();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn hello() {
|
||||||
|
/say Hello, world!
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Conditional Statements
|
## Conditional Statements
|
||||||
Conditional statements are used to execute code based on a condition.
|
Conditional statements are used to execute code based on a condition.
|
||||||
They start with `if` followed by a condition in parenthesis and a block of code.
|
They start with `if` followed by a condition in parenthesis and a block of code.
|
||||||
|
|
Loading…
Reference in New Issue