2016-06-21 12:40:41 -04:00
|
|
|
This guide will describe how mods and their triggers attach to FullScreenShenanigans projects.
|
2016-06-20 17:22:08 -04:00
|
|
|
|
|
|
|
|
# ModAttachr
|
|
|
|
|
|
|
|
|
|
ModAttachr is a module that allows for extensible triggered mod events.
|
|
|
|
|
|
2016-06-20 20:52:47 -04:00
|
|
|
A mod is a custom modification that changes how the game normally runs and/or how the player interacts with the game.
|
2016-06-21 11:32:20 -04:00
|
|
|
Each mod can define any number of events, keyed by string, to call when they are fired.
|
|
|
|
|
When an event is fired in the game, ModAttachr calls the corresponding events of all enabled mods that have a defined event under that name.
|
2016-06-20 17:22:08 -04:00
|
|
|
|
2016-06-21 12:40:41 -04:00
|
|
|
## Adding Mods
|
|
|
|
|
|
2016-06-20 20:52:47 -04:00
|
|
|
A mod can be added with `addMod`.
|
2016-06-21 11:32:20 -04:00
|
|
|
|
2017-01-27 01:19:31 -08:00
|
|
|
```javascript
|
2016-11-26 01:37:59 -05:00
|
|
|
modAttacher.addMod({
|
2016-06-20 20:52:47 -04:00
|
|
|
name: "Infinite Health",
|
|
|
|
|
events: {
|
2017-01-27 01:19:31 -08:00
|
|
|
"onModEnable": () => {
|
2016-06-21 12:40:41 -04:00
|
|
|
// event code when the mod is enabled
|
2016-06-20 20:52:47 -04:00
|
|
|
},
|
2017-01-27 01:19:31 -08:00
|
|
|
"onModDisable": () => {
|
2016-06-21 12:40:41 -04:00
|
|
|
// event code when the mod is disabled
|
2016-06-21 11:32:20 -04:00
|
|
|
},
|
2017-01-27 01:19:31 -08:00
|
|
|
"onBattleStart": () => {
|
2016-06-21 11:32:20 -04:00
|
|
|
// event code when a battle starts
|
2016-06-20 20:52:47 -04:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
enabled: false
|
|
|
|
|
});
|
|
|
|
|
```
|
2016-06-21 12:40:41 -04:00
|
|
|
|
2016-06-21 11:32:20 -04:00
|
|
|
## Event Hooks
|
2016-06-21 12:40:41 -04:00
|
|
|
|
2016-06-20 20:52:47 -04:00
|
|
|
When a mod is enabled, its `onModEnable` event is called; when a mod is disabled, its `onModDisable` event is called.
|
2016-06-21 11:32:20 -04:00
|
|
|
A mod can be toggled with `toggleMod`.
|
|
|
|
|
|
2017-01-27 01:19:31 -08:00
|
|
|
```javascript
|
2016-06-21 12:40:41 -04:00
|
|
|
// Enables, disables, and toggles the mod.
|
2016-11-26 01:37:59 -05:00
|
|
|
modAttacher.enableMod("Infinite Health");
|
|
|
|
|
modAttacher.disableMod("Infinite Health");
|
|
|
|
|
modAttacher.toggleMod("Infinite Health");
|
2016-06-20 20:52:47 -04:00
|
|
|
```
|
2016-06-21 12:40:41 -04:00
|
|
|
|
|
|
|
|
To fire events use the module's `fireEvent` function.
|
2016-06-20 17:22:08 -04:00
|
|
|
|
2017-01-27 01:19:31 -08:00
|
|
|
```javascript
|
2016-11-26 01:37:59 -05:00
|
|
|
// Fires the onBattleStart event for all mods.
|
|
|
|
|
modAttacher.fireEvent("onBattleStart");
|
2016-06-21 11:32:20 -04:00
|
|
|
```
|
|
|
|
|
|
2016-06-21 12:40:41 -04:00
|
|
|
To fire an event for one mod, use `fireModEvent`.
|
|
|
|
|
|
2017-01-27 01:19:31 -08:00
|
|
|
```javascript
|
2016-11-26 01:37:59 -05:00
|
|
|
modAttacher.fireModEvent("onBattleStart", "Infinite Health");
|
2016-06-21 12:40:41 -04:00
|
|
|
|
2016-06-21 12:47:14 -04:00
|
|
|
// Passing in additional arguments.
|
2017-01-27 01:19:31 -08:00
|
|
|
const opponent = new Opponent();
|
2016-11-26 01:37:59 -05:00
|
|
|
modAttacher.fireModEvent("onBattleStart", "Infinite Health", opponent);
|
2016-06-21 11:32:20 -04:00
|
|
|
```
|
|
|
|
|
|
2016-07-19 09:27:28 -07:00
|
|
|
More can be read about ModAttachr on its [Readme](https://github.com/FullScreenShenanigans/ModAttachr/blob/master/README.md).
|