Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API for repeating, interactive scenes #547

Open
amyjko opened this issue Aug 3, 2024 · 2 comments
Open

API for repeating, interactive scenes #547

amyjko opened this issue Aug 3, 2024 · 2 comments
Labels
enhancement New or improved feature library Anything related to standard APIs. needs design When an enhancement is not yet designed

Comments

@amyjko
Copy link
Collaborator

amyjko commented Aug 3, 2024

What are you trying to do that you can't?

The Scene API is a reasonable way to make a fixed sequence of content. But it's not a reasonable way to make a sequence of interactive things. For example, a student was trying to do this:

  1. Show starting instructions for a fixed period of time
  2. Allow an infinite time to guess
  3. Show a result for a fixed period of time
  4. Return to step 1

Scene can implement steps 1-3, but not 4.

What is your idea?

Perhaps add another property of Scene that allows it to loop indefinitely, wrapping around to the first item after the last is done.

@amyjko amyjko added enhancement New or improved feature library Anything related to standard APIs. needs design When an enhancement is not yet designed labels Aug 3, 2024
@nathanbek
Copy link

Hi Amy,

I've been thinking through the design modifications for the repeating, interactive scenes. Here's the concise plan I'd propose:

New Loop Flag:
Add an optional boolean property (e.g. loop) to each Scene definition. When true, the scene will automatically wrap around to its first output after reaching the last one.

Modifying Scene Logic:
In the Scene's next() method, detect when the scene reaches the end of its outputs. If the loop property is enabled, reset the internal output index to 0 so that the scene seamlessly restarts. Optionally, we can allow a repeatDelay to insert a pause between iterations.

Resetting Interactive State:
For interactive elements (like those using @boolean), ensure that any waiting or stateful behavior is reset at the start of each loop. This ensures that user interactions or dynamic updates work as expected on each iteration.

Backward Compatibility:
By default, the new looping behavior would be disabled. This keeps the existing Scene API behavior unchanged unless authors explicitly enable looping.

Progress and State Tracking:
While the Progress class isn’t directly affected, if we choose to integrate loop awareness there (for debugging or serialization), we might consider a cycle counter or flag to differentiate loop iterations.

Overall, this design should allow for interactive scenes where fixed instruction periods can be followed by indefinite interactive phases and then result displays, before looping back to the start. Let me know what you think!

@amyjko
Copy link
Collaborator Author

amyjko commented Feb 9, 2025

I think this is a great start; the looping functionality and defaults seem well considered.

The only thing I'm unsure about is the interactivity. I built out an interactive scene example in this project, for example, and I'm not sure the interactivity I built is expressible with Scene:

https://wordplay.dev/project/4e924660-1397-413c-bb44-d597e3c5378d

Want to take a look at that project and see if a Scene could be used instead? (Maybe the use of a boolean flag is enough, but if not, we might also want to consider some more expressive feature for it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New or improved feature library Anything related to standard APIs. needs design When an enhancement is not yet designed
Projects
None yet
Development

No branches or pull requests

2 participants