User Tools

Site Tools


4rpl:commands:func

Index

Function Declaration

Syntax

:FunctionName

Description

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 '@FunctionName' call. The end of a function block is either the end of the script or the beginning of another function, whichever comes first.

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” on the Index page.

Examples

# --- Roll a 100 sided die-------------- 
# --- Return true or false randomly. 
# --- The value on the stack is the percentage chance. 
# --- [ Chance_in_100 -- true/false] 
:chance 
	# Take an item from the stack, divide by 100, 
	# then compare to a random float. 
	100.0 div RandFloat gt
4rpl/commands/func.txt · Last modified: 2021/01/15 09:12 by Sanian