Reading Parchment state from outside Parchment

I’m about to start implementing a small point-and-click adventure game in p5.js, and one of its several gimmicks is that some rooms will be IF instead. To do this I plan to just have parchment and the p5.js canvas sitting next to each other, and resize them or change their visibility as the player moves between rooms. I think this is basically straightforward, but if anyone has tried anything similar and knows of any gotchas, I’d love to hear about them :‌)

What I’m not sure at all how to do, though, is read state from Parchment in order to make the necessary changes. I can imagine this working either via actively monitoring Parchment state from outside, to detect things like inventory changes and location changes, or by inducing Parchment to call some javascript when particular events happen.

I would very much appreciate any guidance or relevant documentation or similar project links anyone has to offer before I jump in and try to hack something together on my own, because it has the feeling of something I could very easily make way too hard on myself. Thanks!

I recommend looking into Vorple rather than pure Parchment. It will make calling other JS functions much simpler.

1 Like

Seconding the recommendation for Vorple. One of its core features is being able to execute arbitrary JavaScript code from within the Z-machine and receive its results, which is a solid foundation for any sort of state-exchanging.

Wonderful, this is exactly what I needed to hear, thanks to both of you! Looks well documented and like exactly the right tool, so I think I’m set for now, but I’ll likely be back when I run into problems :‌P