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
function A()
endHowever, in Nature scripts, you declare functions that are called from Nature. Example:
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
Arg1: Int, Key Arg2: Int, State
OnSendPacket
Arg1: Packet, SendPacket Arg2: BoolRef, Cancel
Called when sending a packet to the server
OnSendPacket2
Arg1: Packet, SendPacket Arg2: BoolRef, Cancel
Called when sending a packet to the server, this is the final event to be called
Next, let's write the function that handles the processing to be performed within this callback function.