small victory: i managed to implement a love2d dialogue textbox system in fennel using only coroutines

this is the *entire* code to use this

render-text literally is just a coroutine closure that gets resumed every tick, and automatically handles how to render it based on the current time

this is what the closure actually looks like if you're curious! gist.github.com/Archenoth/d189

(i named it .clj because github doesn't recognize fennel)

basically, every tick, the coroutine to render a single line of dialogue resumes with a new time in scope, and based on that, renders a subset of text

after it renders a full line, it continues to a new yield loop to render the bouncy triangle at the bottom to note you can progress

and when the coroutine finally finishes, a new line takes its place

the magic is that resuming a coroutine just jumps right back to the place i yielded from, so i can break this coroutine into tiny pieces that get rendered every frame

meaning, i only ever need to interact with it in once place after making it; it's completely self-contained!

(i wonder how this compares to how scheme continuations work?)

oh, and if you are curious about the faces i drew in literally 5 seconds in mspaint because i needed something to test with, here they are!

anyway, fennel continues to be a super-cool language that i like lots, so it's cool finding excuses to use it more

Sign in to participate in the conversation
Awoo Space

Awoo.space is a Mastodon instance where members can rely on a team of moderators to help resolve conflict, and limits federation with other instances using a specific access list to minimize abuse.

While mature content is allowed here, we strongly believe in being able to choose to engage with content on your own terms, so please make sure to put mature and potentially sensitive content behind the CW feature with enough description that people know what it's about.

Before signing up, please read our community guidelines. While it's a very broad swath of topics it covers, please do your best! We believe that as long as you're putting forth genuine effort to limit harm you might cause – even if you haven't read the document – you'll be okay!