+1 vote
by (370 points)

So I am working with Twine 2.1.3 and Harlowe 2.0.1 and what I'm trying to do is get the cycling links. I tried both versions, and they always a message that pops up saying something like "Sorry to interrupt, but this page's code has got itself in a mess. (Uncaught Syntax: missing) after arguement list) (This is probably due to a bug in the Harlowe game engine.) By versions I mean where cycling links uses the name of the clickable link, and the other version where you use the name of the clickable link has a passage of a different name, if that makes sense. 

Here is my code, using version two:

<center><b>haikyuu!! messenger</b></center>
|output>[]
{(set: $count to 0)
(Live: 1s)[(set: $count to it + 1)
(if: $count >= 1)[(replace: ?output)[<b>$uName:</b> hi.]]
(if: $count >= 2)[(append: ?output)[<br><b>catman:</b> hey babe]]
(if: $count >= 3)[(append: ?output)[<br><b>$uName:</b> how are you?]]
(if: $count >= 4)[(append: ?output)[<br><b>catman:</b> not much]]
(if: $count >= 5)[(append: ?output)[<br><b>$uName:</b> what did you do today?]]
(if: $count >= 6)[(append: ?output)[<br><b>catman:</b> i had to help lev with his training]]
(if: $count >= 7)[(append: ?output)[<br><b>$uName:</b> is he getting any better?]]
(if: $count >= 8)[(append: ?output)[<br><b>catman:</b> a little bit]]
(if: $count >= 9)[(append: ?output)[<br><b>$uName:</b> (set: $ThirdYears to "typing...")
 <tw-link class='cyclingLink' data-cycling-texts='["i know you have a girlfriend", "why didn't you tell me?", "what kind of practices were you guys doing?"]' onclick='clickCyclingLink(this, "$ThirdYears");'>$ThirdYears</tw-link><br>
<br>(link: "send")[{
(if: $ThirdYears is "i know you have a girlfriend")[(goto: "First Passage")]
(elseif: $ThirdYears is "why didn't you tell me?")[(goto: "Second Passage")]
(else:)[(goto: "Third Passage")]}]]]
(if: $count >= 10)[(stop:)]]}

Did I copy and paste wrong? Or is it really a bug? Or is it the timed dialogue making things difficult?

1 Answer

+1 vote
by (154k points)

NOTE: When referring to third-party code like the cycling link examples you mention in your question it helps if you include a link to the web-site/forum post you obtained that example from, this ensures the people answering your questions know exactly which examples you meant.

Based on the name of the Javascript clickCyclingLink() function you are using I will assume you are referring to Furkle Industries's Cycling Links, I will also assume you have added the relevant code to your story's Story Javascript area.

There are a number of logic/syntax errors in your example, one of which is causing the error you are seeing.

1. The (if:) macros you are using to test the current value of $count are currently mutually inclusive, this means that as the value of $count increases each previously checked condition is also true which in turn results in the current contents of the output named hook being overwritten every second. You should be using (else-if:) macros for the 2-8 value checks and an (else:) macro for the 9 value check.

2. The (stop:) macro should be in the 9 value check because there is no more content being added to the output named hook after that, you should stop your timer thread as soon as possible because they interfere with a Reader's ability to interact with the page.

3. One of the values in your data-cycling-texts array contains a singe-quote character and this is causing the error message you are seeing. Some characters in HTML/Javascript have special meaning and the singe-quote is one of them, because of this you will need to escape that character and in this use-case you do this by replacing it with &#39; (which is the HTML code for singe-quote)

The following is a modified version of your original example:

<center><b>haikyuu!! messenger</b></center>
|output>[] {
	(set: $count to 0)
	(set: $ThirdYears to "typing...")
	(Live: 1s)[
		(set: $count to it + 1)
		(if: $count is 1)[
			(replace: ?output)[<b>$uName:</b> hi.]
		]
		(else-if: $count is 2)[
			(append: ?output)[<br><b>catman:</b> hey babe]
		]
		(else-if: $count is 3)[
			(append: ?output)[<br><b>$uName:</b> how are you?]
		]
		(else-if: $count is 4)[
			(append: ?output)[<br><b>catman:</b> not much]
		]
		(else-if: $count is 5)[
			(append: ?output)[<br><b>$uName:</b> what did you do today?]
		]
		(else-if: $count is 6)[
			(append: ?output)[<br><b>catman:</b> i had to help lev with his training]
		]
		(else-if: $count is 7)[
			(append: ?output)[<br><b>$uName:</b> is he getting any better?]
		]
		(else-if: $count is 8)[
			(append: ?output)[<br><b>catman:</b> a little bit]
		]
		(else:)[
			(stop:)
			(append: ?output)[\
				<br><b>$uName:</b> \
				<tw-link class='cyclingLink' data-cycling-texts='["i know you have a girlfriend", "why didn&#39;t you tell me?", "what kind of practices were you guys doing?"]' onclick='clickCyclingLink(this, "$ThirdYears");'>$ThirdYears</tw-link>\
				<br><br>\
				(link: "send")[{
					(if: $ThirdYears is "i know you have a girlfriend")[(go-to: "First Passage")]
					(else-if: $ThirdYears is "why didn't you tell me?")[(go-to: "Second Passage")]
					(else:)[(go-to: "Third Passage")]
				}]\
			]
		]
	]
}

 

by (370 points)
Thank you so much greyelf! This works perfectly! How did you know how to do that? And I'm sorry for not including details like third party coding. I actually didn't know it was considered a third party coding. How do you know if it's third party coding?
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.
...