-
Notifications
You must be signed in to change notification settings - Fork 2
Intercepting events
Today, we'll be looking at using Equilimod's events system to intercept events from Equilinox.
To start off with, we'll need to set up a blank mod, like the one shown here. It should look something like this:
ModRegistry.registerMod(new Mod({
name : "Event interception",
version : "1.0.0-beta",
author : "pcr3w",
description : "A demonstration of intercepting mods with Equilimod.",
init : function() {
// our event interception will take place here
}
}));
We can now use the EventBus
to subscribe to certain event types. Full documentation for all of the event classes can be found here, but today we'll just need to use the PRE_GAME_UPDATE
event.
Each event you subscribe to will need a listener - a function which will be provided with the event data every time the event occurs. The static method on
is used to do this:
// the 'init' function for our mod
init : function() {
// this will add an event handler to be called before every update tick of the game
// the event-data type will just be 'GameEvent'
EventBus.on(Events.PRE_GAME_UPDATE, function(event) {
// don't worry too much about this code for now - we'll be looking at it in more detail at a later date
// all this does is send a notification to the user
EquilinoxGuis.notify("Mod information", "This has been called by an event handler.", GuiRepository.DNA_256);
});
}
The above code, when used with a mod, should result in something like the following appearing in-game:
There are currently several other event types with Equilimod, but they will not be covered in any near tutorials.
Next time, we'll be moving onto actual game content, looking at adding our own custom tasks to the game.
Thanks for visiting this wiki. Don't forget to check out Equilinox!
The wiki and the modding framework are still heavily under development, so not all content is available yet.