From f43693ec190c6377efd093147ca8d155b0f3abe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20H=C3=B6lting?= <87192362+moritz-hoelting@users.noreply.github.com> Date: Sat, 6 Apr 2024 12:23:13 +0200 Subject: [PATCH] Add note about main function requirement and function calls --- src/content/docs/guides/syntax.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/content/docs/guides/syntax.md b/src/content/docs/guides/syntax.md index fd00a07..a66b4a1 100644 --- a/src/content/docs/guides/syntax.md +++ b/src/content/docs/guides/syntax.md @@ -44,6 +44,10 @@ fn main() { ``` 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 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. @@ -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 = "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 are used to execute code based on a condition. They start with `if` followed by a condition in parenthesis and a block of code.