Event Forwarder package

Name: Event Forwarder
By AdamO on Discord

This is a super-simple, but handy, package!

Often you’ll want to use an event to trigger logic on an entity, but you want to call that function on all children of an entity, or you want to call a function by name if it exists rather than directly referencing it in the event property.

The Event Forwarder package lets you do both - you can define up to 4 function names to call, and then simply hook events into them, and they’ll be called on all scripts on your entity. You can also tick “callOnChildren”, and the functions will be called on all children of this entity too!

An example use case - you have a map with various types of doors - some are meshes, some are voxels, and they have different scripts for opening and closing based on their type. But they all have one thing in common - a function called “Open” and a function called “Close”. You can use an event to open them all, and another to close them all, by sending those events to the EventForwarderScript on the parent of the doors. The EventForwarderScript can have FunctionA as “Open” and FunctionB as “Close” and pass those messages on to all children, regardless of what exact scripts they have!


An example using Calendar Events, Event Forwarder and Property Changer packages:

  • In this example, I have a CalendarEventScript with a custom event (set up for the time I recorded the video).
  • That has “active” and “inactive” events which are passed to CallFunctionA and CallFunctionB on the radioactive waste barrel, on the EventForwarderScript.
  • That script is set up to call “SetProperty” in function A, and “ResetProperty” in function B - these get called on all scripts on this entity.
  • SetProperty and ResetProperty are called on BOTH PropertyChangerScripts on the barrel. These are set up to change the mesh to a pirate barrel, and increase the bounce height on the RotateAndMoveScript.
  • You can see when my custom event starts, the barrel turns into a pirate barrel and bounces higher. When it ends, it goes back to the radioactive barrel, and a low bounce height.
  • You can use these 3 packages together in the same way to change all sorts of things in your own game on custom events or Crayta events, e.g. make your game pirate-themed during Cursed Galleons!

2 Likes