Ticker mod
Example apps / ticker-mod / v0.1.0
Node mod
A Node mod with no window: it logs V's position every ten seconds, each game event and each state change.
Simulated game
starting
Mod log
// Ticker mod: no window, only the log. Its output goes to
// red4ext/logs/rednode-mods.log, each line tagged [ticker-mod].
import { game } from 'rednode';
setInterval(async () => {
try {
const p = await game.player.position();
console.log(`V is at ${p.x.toFixed(1)}, ${p.y.toFixed(1)}, ${p.z.toFixed(1)}`);
} catch (err) {
console.log(`No position: ${err.message}`);
}
}, 10000);
game.on('PlayerPuppet.OnGameAttached', (e) => console.log(`Game event ${e.name} = ${e.value}, frame ${e.frame}`));
game.onState((s) => console.log(`State: ${JSON.stringify(s)}`));
console.log('Ticker mod started');
REDnode runs JavaScript. The rednode package also has TypeScript types, so an editor checks these calls; compile TypeScript to .mjs first.
{
"id": "ticker-mod",
"name": "Ticker mod",
"version": "0.1.0",
"author": "Edgemodders",
"description": "A Node mod with no window. Logs V's position every 10 seconds, and every game event and state change, to rednode-mods.log.",
"main": "mod.mjs",
"open": true
}
The manifest names the package and says how REDnode runs it. Its fields are in Overlay apps.
How it works
A mod does not need a window. Its log lines show in the Mod log and in red4ext/logs/rednode-mods.log.
What it uses
console.log game.player.position game.on game.onState
Try this
- Load a save below and watch the event line.
Use it
Copy the files into red4ext/plugins/REDnode/apps/ticker-mod/ in the game folder, or start your own package from them: change id and name in the manifest first. The whole folder is on GitHub.