Skip to content

Callback Function ​

Define a function that connects the Nature client and the script, and retrieve events.

How to write ​

Typically, function definitions in Lua are written as

lua
function A()
end

However, in Nature scripts, you declare functions that are called from Nature. Example:

lua
A(function()
end)

We will refer to these as callback functions from here on.

List of Callback Functions ​

The currently registered callback functions are as follows:

OnStart ​

This is the first function to be loaded automatically. It is not called by .script reload command.

OnLoad ​

This function is called when the script is loaded. It is called by .script reload command.

OnTick ​

This is tick from the localplayer.

OnRender ​

This is the callback function for drawing.

OnKey ​

This is called when a key is pressed.

Next, let's write the function that handles the processing to be performed within this callback function.