Addons
Addons are a new way to create integrations with LHM. Up until this point, only the custom HUD's code had access to game data feed, which meant whatever you wanted to do, it had to be done in the browser environment. Addons work on server environments - they are basically NodeJS apps with CS:GO GSI Event emitter hooked into them. It means that you don't need to create a custom HTTP server with a parser just to receive information from CS:GO, you have all that out of the box, so you can focus on integrations and features you want to create.
Quick idea what you could achieve with it. You can:
- Send signals to ATEM to play custom music on half-time
- Send MIDI signal to stage to start animation on LEDs in front of the crowd
Requirements (IMPORTANT):
Basic addons, that do not use external dependencies, have no requirements for usage. But if a developer specified those inside package.json, you need to have NodeJS / npm installed for LHM to fetch them from the internet.
How to start an addon?
Assuming you already created or got an addon, it should just display inside the Addon tab. Toggle the addon, so it will go through the process of making sure it has all necessary dependencies, installing them, and launching it. After launch, the settings panel will be available.
How to create an addon?
Requirements:
- NodeJS 18.X
- JavaScript skills
We work on making creating addons as straightforward as possible. For now:
- Fork and clone this repository: https://github.com/lexogrine/lhm-addon-example
- Create a new folder (only a-z A-Z 0-9 characters) in %appdata%/hud-manager/addons and copy there content of the cloned repository
- Open terminal / cmd in that location and do
npm i
Right now, addon is ready to be launched from LHM.
API
Read code and comments in index.js
to make yourself familiar with the API.
In index.js
LHM adds to global context a few functions:
loadConfig(async () => void)
- this function registers a callback that creates a settings panel. Returned value should be an array of inputs (just as in panel.json in the HUDs). Because this function is async, you can hit other APIs to construct what inputs you need, before Addon fully launches.
onStart(async ({ CSGOGSI, config, close, onConfigChange }) => void)
- inside this callback you should register all your game events, servers, listeners. Inside this function you have access to CSGOGSI
(its instance of csgogsi class, it's being supplied with game data in real time), config
(inital values for the config, which are values from the last addon startup), close
function (it force closes addon programatically), and onConfigChange
, so you can listen for changes and update addon behaviour.
onClose(async ({ CSGOGSI, config }) => void)
- cleanup function. Clean all your listeners and close all servers you initiate, or it will create a memory leak or blocked ports. Not significant probably, but good memory management is something to keep in mind.
To share addon, run npm run pack
. It will create a sharable zip, that you just drag'n'drop inside the Addon tab.