Function (Structure) — Skript

Addon: Skript · Category: Structure · Since: 2.2, 2.7 (local functions)

Syntax

[local] function <.+>

Description

Functions are structures that can be executed with arguments/parameters to run code. They can also return a value to the trigger that is executing the function. Note that local functions come before global functions execution

Examples

function sayMessage(message: text):
	broadcast {_message} # our message argument is available in '{_message}'
local function giveApple(amount: number) :: item:
	return {_amount} of apple
function getPoints(p: player) returns number:
	return {points::%{_p}%}

View source