Hi! I’m very new to Twine and I’ve slowly been figuring things out as I go.
I was curious to see if there was a way to implement a brief pause (~1 second) after every punctuation mark when using the basic Harlowe typewriter effect in order to better match the flow of spoken word, or to add some dramatic flair to an ellipses.
My current test passage looks like this:
(set: $typewriterText to "Test. This sentence is a test. I am testing Twine, have a nice day.")
{
(set: $typewriterPos to 1)
|typewriterOutput>[]
(live: 5ms)[
(append: ?typewriterOutput)[(print: $typewriterText's $typewriterPos)]
(set: $typewriterPos to it + 1)
(if: $typewriterPos is $typewriterText's length + 1)[
(stop:)
]
]
}
The intent is to have text that, when run, would display something like:
"Test. (Pause.) This sentence is a test. (Pause.) I am testing Twine, (Pause) have a nice day. (Pause.)"
I’ll keep this in mind, though that’s not really what I was asking about - I was wondering how to add a delay after every punctuation point, if that’s possible.
With all the caveats of “delayed text is best in small doses” we always talk about…
I don’t usually deal with these kinds of things, but it almost seems like to avoid changing display speed manually for every sentence, you’d want to create a CSS text style for your printout text and somehow within the style parse for the period character or any punctuation you want a pause for and have it delay before proceeding.
Depending on how complicated this is, maybe the style just has a built-in hesitation before proceeding, and your style could append text so you’d just separate the sentences that need pauses under that style so they flow together.
I don’t use styles too often so I don’t know how to do this or if it’s actually possible, but hopefully someone can verify if this can be done.
I also wonder if there’s a way to make some kind of “widget” or macro in Harlowe within the delay code where you could automatically include a longer pause before proceeding inline like you’ve indicated
There might be a more elegant way of doing this (it’s been a while since I looked at Harlowe), but the following works by flagging any occurrence of "." or "," and refraining from appending to the typewriter output until a certain amount of time has passed.
Note: 750ms is 3/4 of a second.
(set: $typewriterText to "Test. This sentence is a test. I am testing Twine, have a nice day.")
{
(set: $typewriterPos to 1)
(set: $pause to false)
(set: $timeStamp to 0ms)
|typewriterOutput>[]
(live: 5ms)[
(if: $pause is false)[
(set: $timeStamp to time)
(append: ?typewriterOutput)[(print: $typewriterText's $typewriterPos)]
]
(if: $typewriterText's $typewriterPos is "." or ",")[
(if: time < ($timeStamp + 750ms))[
(set: $pause to true)
](else:)[
(set: $pause to false)
(set: $typewriterPos to it + 1)
]
](else:)[
(set: $typewriterPos to it + 1)
]
(if: $typewriterPos is $typewriterText's length + 1)[
(stop:)
]
]
}
Edit: I noticed that you mentioned an ellipsis as a potential pause as well. There is a single unicode character for an ellipsis ("…") that you can check for, but if you want to pause after three individual periods ("..."), you can do so quite easily. If you find a "." character and the proceeding character ($typewriterPos + 1) is also a "." then you can skip the pause condition.
Actually, the code I provided can be modified to check for a certain pattern of characters, such as [pause] or [!] or whatever is desired. This is great to keep the pause feature independent of the punctuation. Good call, man!
@UnaOwenIf you wish to have that as a feature instead, I’ll modify the code for you.