Create, Compete & Win at Redbrick Connect 2024! 🎉

Signal

Module for inter-script communication.

Class used for communication between client scripts or server scripts. Signals can be used to run functions that exist in different scripts, and so on.

ℹ️

You must use the Event Manager module for signaling between client and server scripts.

Methods

.send()

.send(name, params)

Sends a signal with the name corresponding to the name. The signal is passed throughout the client script or throughout the server script. You can pass the parameters with the params option.

.addListener()

.addListener(name, callback)

Registers the function to run when a signal corresponding to name is received. If there are any parameters sent at the time of sending, receive them and deliver them to the callback function.

.removeListener()

.removeListener(name, callback)

If you have a specific function registered for the signal that corresponds to the name, remove it from the list of registered functions.

Example

  • ObjectA
// This Object listens signal
function Start() {
  REDBRICK.Signal.addListener("MOVE", (params) => {
    this.move(params.x, params.y, params.z, params.duration);
  });
}
  • ObjectB
// This Object sends signal
function OnKeyDown(event) {
  if (event.code === "KeyM") {
    REDBRICK.Signal.send("MOVE", { x: 0, y: 1, z: 0, duration: 1 });
  }
}