Skip to main content

Specifiers

A function specifier is a keyword that modifies the behavior of a function. It appears before the fn keyword in the function declaration. Multiple functions may exist with the same name, but different specifiers. The function specifier may change how the function must be called.

Normal functions

Most functions will be declared without a specifier.

fn MyFunction() {
// ...
}

fn Example() {
MyFunction // calls MyFunction
}

Set function

The set fn specifier is used to declare a function that performs a set, whatever that means in the context of the function.

It is invoked by using an assignment statement (a statement involving an = sign).

set fn this.PowerLevel = power {
DrawPowerLevel(power)
}

fn this.Example() {
PowerLevel = 9000
}

Delete function

The delete fn specifier is used to declare a function that performs a delete, whatever that means in the context of the function.

It is invoked by using the delete keyword.

delete fn this.Healthbar() {
// ...
}

fn this.Example() {
delete Healthbar
}

Await functions

The await fn specifier is used to declare an asynchronous function. That is, a function that does not return immediately, and may instead wait for a number of ticks before returning. Any functions which do not return immediately should be declared as an await fn so callers know what to expect.

When a function is called using the await, once, on or with keywords, the compiler looks for a function with both the required name and the await fn specifier, and it will error if it cannot find one.

Unlike other programming languages, in Easel any function can perform an await, even if it is not inside a function declared as an await fn. But it is good practice to declare a function as an await fn if it performs an await so callers know what to expect.

await fn WaitThenGiveMeANumber() -> value {
// wait for 10 ticks before returning
await Tick(10)
return 123
}

fn Example() {
let x = await WaitThenGiveMeANumber
}

Entrypoint functions

The page fn specifier is used to declare a function that is the entrypoint when a user navigates to a particular page in the game. The game fn specifier is used to declare a function that is the entrypoint when a user navigates to play the game. See the entrypoints page for more information.