5930e5d160
- 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
18 lines
524 B
JavaScript
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!");
|