+1 vote
by (2.1k points)
edited by

I'm using Twine 2.1.3(x64) standalone on a Windows 10 computer with the SugarCube 2.18.0 format.

I'd like to use a button to have the passage display text with the 'typed.js' plugin typing it out. As I have it, without using a button it looks like this and works fine. It starts the delays from the beginning of the passage as expected and types out the text with expected delays between each line.

<div class="computer">
<<set _areas = ["BRIDGE", "CRYOSTORAGE", "LABORATORY", "MESS HALL", "ENGINES"]>>\
	<<for _i=0; _i < _areas.length ; _i++>>\
		<<if _i!= (_areas.length-1)>>\
			<<print "<div class=\"typed-speed40-delay800\">..." + _areas[_i] + " FULLY OPERATIONAL</div>">>\
		<<else>>\
			<<print "<div class=\"typed-speed40-delay800\">..." + _areas[_i] + "</div>\<div class=\"typed-speed60-delay400\"> ... ... ...</div>">>\
			<<print "<div class=\"typed-speed40-delay800\">ERROR DETECTED IN ENGINES</div>">>\
		<</if>>\
	<</for>>\
</div>

The moment I try to encapsulate it within a button it instead prints out the whole body of text without the look of manual typing that 'typed.js' would apply. Now I am pretty sure it is an issue of timing, but I am not entirely sure where it is or what to do about it as I don't have extensive knowledge of how the story passage is rendered. Here is the code I use

<div class="computer">
<<button "Initialize ">>\
	<<replace ".computer">>\
		<<set _areas = ["BRIDGE", "CRYOSTORAGE", "LABORATORY", "MESS HALL", "ENGINES"]>>\
		<<for _i=0; _i < _areas.length ; _i++>>\
			<<if _i!= (_areas.length-1)>>\
				<<print "<div class=\"typed-speed40-delay800\">..." + _areas[_i] + " FULLY OPERATIONAL</div>">>\
			<<else>>\
				<<print "<div class=\"typed-speed40-delay800\">..." + _areas[_i] + "</div>\<div class=\"typed-speed60-delay400\"> ... ... ...</div>">>\
				<<print "<div class=\"typed-speed40-delay800\">ERROR DETECTED IN ENGINES</div>">>\
			<</if>>\
		<</for>>\
	<</replace>>
<</button>>
</div>

 Would anybody be able to point me in a direction, or help me rewrite this in a way that gives me the desired results? 

1 Answer

0 votes
by (2.1k points)
selected by
 
Best answer
I've gotten around this by simply having the typed.js section appear in another passage. It would still be nice if there were a way to have it in the same passage, but it looks like there is not. I'll close the question with this answer at least for other people with the same question.
...