Why Scripts Need to Communicate
As your setup grows, you may split logic across several script files. One script might track a score while another reacts to it. Rhino itself does not provide cross-file storage, so you rely on mechanisms the host mod exposes.
Approaches That Work
- Global objects: Some host mods inject a shared global namespace that all scripts can read and write. Check the mod's docs for whether this exists and what it is called.
- Persistent storage: Many mods offer a key-value store for scripts. Write a value in one script and read it in another using the same key. This also survives game restarts.
- Events as a channel: Have one script fire a custom event and another listen for it. This decouples the scripts and avoids load-order problems.
Avoiding Pitfalls
Do not rely on variables declared with var or let at the top level of one file being visible in another unless the host mod explicitly shares scope. Assume each file is isolated by default. When using persistent storage, namespace your keys with a prefix to avoid collisions with other scripts or the mod itself. Always test that data written in one script is actually readable in the other before building complex logic on top.








