Problem with Typewriter

0 votes
asked Mar 12 by Brugtz (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>>
			<<stop>>
		<<else>>
			<<append ".typewriter">>$args[0][_textArrayLength]<</append>>
			<<set _textArrayLength ++>>
		<</if>>
	<</repeat>>
<</widget>>

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
answered Mar 12 by idling (10,470 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
answered Mar 13 by greyelf (88,790 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.

Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...