0 votes
by (440 points)

Hey guys, i need help of all you...

I have this code for make typewriter effect.


<<widget "typewriter">>
	<div class = "typewriter"></div>
	<<set _textArrayLength to 0>>
	<<repeat 0.01s>>
		<<if _textArrayLength gte $args[0].length>>
			<<append ".typewriter">>$args[0][_textArrayLength]<</append>>
			<<set _textArrayLength ++>>

Base code for cookbook of twine... But i have one great problem...


If in the text have any variable (ex. $test) que typewriter effect go print "$teste" and not your value set.

Any method for change this?


I need this typewriter print values too.

2 Answers

+1 vote
by (23.6k points)

You can integrate the variable into the text before passing it to your typewriter widget like this:

<<set $name to "Johnny Thunder">>
<<set $sentence to "My name is " + $name +".">>
<<typewriter $sentence>>


+1 vote
by (159k points)

The Typewriter Effect recipe in the Twine Cookbook is a very basic implementation of that effect.

You may want to switch to using the TypedJS Integration Module that can be found on the SugarCube 2 web-site instead, because that module does support story variables embedded within the marked plain text.