Skip to content

DSL: functions

Timothé ROSAZ edited this page Sep 25, 2025 · 1 revision

Some spell files can be a function instead.

  • Either move the file in the /functions folder (instead of /spells) ;
  • Either use the @function annotation at the start of your spell.

Declaration

All functions will have the following annotations :

  • @function([string]) with an optional identifier. If the identifier is different from the file-name, it will be used instead.
  • @param(<string>, <string>) declare a parameter. You can have as much as needed.
    • The first argument is the name of the variable that will be injected.
    • The second argument is the type of the parameter.
  • @output(<string>, <string>, [boolean]) declares the output of the function.
    • The first argument is the name of the variable to output.
    • The second argument is the type of the output.
    • The last argument is optional, default value is false. If true, it will consider the output as a list instead of a single element.

Example

A basic example can be:

@function("add_numbers")
@param("a", "number")
@param("b", "number")
@output("c", "number")

%c = %a + %b;

This method can then be used in a spell like this :

%solution = add_numbers(35, 7);
send to %caster message "The answer is %solution.";

Clone this wiki locally