Event.AddListener
Skip to content
mnscript
Event.AddListener(string, string, string) 

Description ​

Registers a callback for an event

Arguments ​

string - The event name (See events documentation)
string - Unique identifier for the callback
string - The name of a global function to be executed when this event happens

Example ​

msc
using Event;

// Links the function OnConsoleCommand to the "ConsoleCommand" event.
// This means when the "ConsoleCommand" event happens, OnConsoleCommand will run.

function OnConsoleCommand(string text){

}

// The first parameter is the name of the event: "ConsoleCommand"
// The second parameter is a unique name which I want to call this event: "commands"
// The third parameter is the name of the function to run when the event happens: "OnConsoleCommand"

Event.AddListener("ConsoleCommand", "commands", "OnConsoleCommand");