-
We're thinking of using Rhai as the scripting language for a generative art toy thing. Users would write Rhai scripts that interact with the rendering engine to make cool images. One tricky requirement that we have is that we need a way to suspend user scripts after they draw a frame, return control to the browser so it can display the rendered frame, and then resume execution of the script where it left off. Something like this would be ideal:
Is something like this possible? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 12 replies
-
Not at this time. You're asking for You have a few choices:
|
Beta Was this translation helpful? Give feedback.
Not at this time. You're asking for
async
(which is essentially suspend-and-resume). Rhai is not async.You have a few choices:
Use another scripting language that is async, such as https://github.com/rune-rs
Run the script in one thread, the rendering engine in another, using a channel to bind the two (check out the
threading
example)Move your render loop outside of the script. Call the script during each frame (or spawn a new engine during each frame)