[DispatchGMS] Callback Dispatcher for GameMaker: Studio

DispatchGMS_logo

Available on the GameMaker Marketplace

DispatchGMS is a callback dispatcher which allows for greater flexibility when managing custom events or extending existing ones.

Multiple callbacks can be added to a single dispatcher and later executed from a single script call. Each script callback can be supplied up to 13 arguments. Additionally, when invoked, a dispatcher can, optionally, override previously set callback script arguments.

[Highlights]

  • Add or insert multiple callbacks into a single dispatcher
  • Various ways to remove callbacks as needed (callback id, script, target, all)
  • Ability to override script callback arguments when invoking dispatcher
  • Enable/Disable dispatchers or specific callbacks
  • “Dynamic Event” scripts allow you to easily adapt dispatchers to existing object events
  • Check if dispatchers contain a specific script or target instance

[Example Code]

——————
Create Event
——————
// Create new dispatcher and add two callbacks
onMousePress = DispatcherCreate();

// Add callback to dispatcher
DispatcherAdd(onMousePress, id, ShowMessage, “Mouse Button was pressed!”);

// Add second callback to dispatcher and cache returned callback handle
cbAddNums = DispatcherAdd(onMousePress, id, AddNumbers, 2, 5);

// Remove second callback from dispatcher
DispatcherRemove(onMousePress, cbAddNums);

——————————
Mouse Button Pressed Event
——————————
// Execute dispatcher
DispatcherInvoke(onMousePress);

——————
Destroy Event
——————
// Destroy and nullify dispatcher
onMousePress = DispatcherDestroy(onMousePress);

——————-
Room End Event
——————-
// Destroy and nullify dispatcher
onMousePress = DispatcherDestroy(onMousePress);

Leave a Reply