This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| 4rpl:commands:func [2021/01/13 23:22] – created virgilw | 4rpl:commands:func [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| < | < | ||
| - | === Syntax === | + | ====== Function Declaration ====== |
| + | |||
| + | ===== Syntax ===== | ||
| : | : | ||
| - | === Description === | + | ===== Description ===== |
| - | Defines the beginning of a function block. | + | |
| - | Choose a unique name for the function. | + | Defines the beginning of a function block. Choose a unique name for the function. Statements after a function block only execute if called by invoking the function with an ' |
| - | Statements after a function block only execute if called by invoking the | + | |
| - | function with an ' | + | A few specific names exist that when used will make that function get automatically called by the game itself under certain circumstances. Read more about it under "Built in Function Callbacks" |
| - | The end of a function block is either the end of the script or the | + | |
| - | beginning of another function, whichever comes first. | + | ===== Examples ===== |
| - | === Examples === | ||
| <code 4rpl> | <code 4rpl> | ||
| # --- Roll a 100 sided die-------------- | # --- Roll a 100 sided die-------------- | ||
| Line 23: | Line 25: | ||
| # then compare to a random float. | # then compare to a random float. | ||
| 100.0 div RandFloat gt | 100.0 div RandFloat gt | ||
| - | </ | + | </ |