Files
gregCore/examples/Js/example_mod/main.js
T
Marvin 5930e5d160
Sponsor Tier Sync / sync (push) Failing after 33s
gregCore CI / build (push) Has been cancelled
feat(examples): add hook subscription to example mods
- JavaScript example now subscribes to greg.PLAYER.CoinChanged hook
- Python example simplified and updated to use hook system
- Go example restructured with proper hook callback implementation
- Rust example extended with on_hook API usage and cleanup functions
- All examples now demonstrate bidirectional communication with the core system
2026-04-20 14:57:51 +02:00

18 lines
524 B
JavaScript

// Plugins/Js/ExampleMod.js
greg.logInfo("JS Example Mod initializing...");
// Subscribe to the player's coin changed hook
greg.on("greg.PLAYER.CoinChanged", (payload) => {
const amount = payload.Data.Amount;
const total = payload.Data.Total;
greg.logInfo(`JS received money update: ${amount} (Total: ${total})`);
// Fire a custom hook back
greg.fire("greg.CUSTOM.JsResponse", {
msg: "JS heard that!",
received_total: total
});
});
greg.logInfo("JS Example Mod initialized!");