Files
gregCore/examples/Python/example_mod/main.py
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

25 lines
688 B
Python

# example_mod/main.py
def on_init():
greg.log_info("Python Example Mod initialized!")
# Subscribe to coin changed hook
def on_coin_changed(payload):
amount = payload["data"]["Amount"]
total = payload["data"]["Total"]
greg.log_info(f"Python received money update: {amount} (Total: {total})")
# Fire a custom hook back
greg.fire("greg.CUSTOM.PythonResponse", {
"msg": "Python heard that!",
"received_total": total
})
greg.on("greg.PLAYER.CoinChanged", on_coin_changed)
def on_update(dt):
# Update logic
pass
def on_shutdown():
greg.log_info("Python Example Mod shutdown.")