0 votes
by (120 points)
Hi, so I'm a complete newbie to both twine and coding alike and I have no idea how to do this. I've been writing stories for quite a while now, and I found twine and decided I want to make some of my stories interactive. What I'm trying to do is set it up so that I can have sentence 1 show up after 2 milisecond, sentence 2 show up after 4 miliseconds, sentence 3 show up after 6 miliseconds, etc. I've tried looking for information on how to do it on the harlowe page, but nothing is specific enough for what I'm trying to do. I gave it a try anyway and it said "Unexpected token :This error message was reported by your browser's Javascript engine. I don't understand it either, but it usually means that an expression was badly written." So that's not very good.

If someone could help me figure what code to use in order to this, I would be very grateful. Also, is it possible to have the game go to the next passage on its own after a certain amount of time instead of having the player click a link and how would you do that? Sorry if this is annoying, I really don't know a thing about coding :(

2 Answers

+1 vote
by (159k points)

Please use the Question Tags to state the name and full version number of the story format you are using, as answers can vary based on this information. Based on you mentioning Harlowe in your question I will assume that you are using Harlowe v2.1.0

You state in your question that you want the next block of text to appear ever 2 milliseconds, which is 2 1000th's of a second, this is a very short time delay and would result in ALL of the blocks seeming to apear at the same time.

Did you actually mean every 2 seconds?

The following example uses a combination of Hidden Hook markup and the (show:) macro to hide & reveal each of the blocks of text, and a story variable combined with some (if:) related macros to control which block is revealed. A (stop:) macro is used within the (live:) macro to halt the associated timer when the last text block is being revealed.

This passage contains 3 hidden blocks of text, each will be revealed after a 2 second delay.

|block1)[The first hidden block of text.]

|block2)[The second hidden block of text.]

|block3)[The third hidden block of text.]

{
(set: $counter to 0)
(live: 2s)[
	(set: $counter to it + 1)
	(if: $counter is 1)[
		(show: ?block1)
	]
	(else-if: $counter is 2)[
		(show: ?block2)
	]
	(else-if: $counter is 3)[
		(stop:)
		(show: ?block3)
	]
]
}

 

0 votes
by (6.2k points)
(live: 0.002s)[Sentence One(stop:)]
(live: 0.004s)[Sentence Two(stop:)]
(live: 0.006s)[Sentence Three(stop:)]

 

by (159k points)

@Deadshot
If you had tested your example you would of noticed that all three sentences will appear instantly on the page.

It is generally recommended to only have a single active (live:) macro per Passage, this is because each (live:) macro creates it's own timer thread and each time one of these threads active it interferes with the readers ability to interact with the page.

Also the correct time unit to use when passing a time delay measured in milliseconds is ms

(live: 2ms)[Sentence One(stop:)]
(live: 4ms)[Sentence Two(stop:)]
(live: 6ms)[Sentence Three(stop:)]

warning: The above example is for demonstrative purposes only, do NOT use it as a solution for the original question.

by (6.2k points)
I did test my example. The only reason the text appeared to appear instantly is because a millisecond is a very short period of time. If you increase the number of time you will be able to notice this.

Also, thank you for telling me you can use ms in (live:) macros.  I thought it would only work with s.
...