Wait a period of time?

Hey,
I just wanted to know if there was a way to wait for a particular period of time (in a gamebook). Currently the only option is to either wait until a key is pressed. The workaround I have found is to insert a blank sound file lasting how long I want to wait for, and restrict continuance until it has finished. However, this makes playing background music whilst progressing impossible.

I want to print something, then have a wait of two seconds, then print something else.

I've got literally no coding knowledge so if someone could break it down for me I'd be very appreciative. Thanks!


The built in wait command (that waits 1 turn). I believe all it does is print a message... I could be wrong.


K.V.

Hello,

image


Code in the JavaScript field:

eval ("setTimeout(function(){addText(\"This is the delayed message.\")}, 3000);")


image


Three seconds later...

image


NOTE:
If you were making a text adventure that looked and acted like a gamebook, you wouldn't have to use JS because the SetTimeout function is a default function in a text adventure.

https://textadventures.co.uk/forum/samples/topic/4772/how-to-make-a-text-adventure-look-like-a-gamebook


That's what I was looking for, yes. How would I apply fonts and colours to the subsequent text? Sorry for asking what must seem like silly questions, I have no experience in this.


K.V.

You can use inline CSS:

eval ("setTimeout(function(){addText(\"<span style='color:purple;'>This is the delayed message.</span>\")}, 3000);")

You can just change it around where it says color:purple;.

I.e., color:green;background:yellow;font-family:Georgia;font-weight:bold;


You can also change the 3000 to 2000 for 2 seconds, 5000 for seconds, or whatever you'd like.


Thank you so much - especially for not being condescending about it! Helped a lot. <3


K.V.

Your welcome!

...and it's no problem!

I learned that right along with you, enjoyed every minute of it, and will probably use that code sometime in the future.


And, since you brought up the thing about not being condescending, I just have to say this:

This is the most polite group of people I've ever encountered. (I was going to say "the most polite forum", but that didn't quite cover it.)

There are people who are brand new to any form of coding asking how to do things here every day, and I've never seen anyone respond impolitely.

There is also at least one person (ahem... yours truly) who asks very silly questions quite frequently, ones which most assuredly drive people crazy (sorry Pixie, mrangel, HK, and everyone else (not XanMag, though; I'm purposefully frustrating him)), but everyone is quite pleasant and super helpful, every single time.

Anyway, I do appreciate your kind words, and you're not so bad, yourself! (Ha-ha!)


I can't help but agree! I haven't received any negative feedback, I just assumed I hadn't spent enough time here because I'm so used to it on every other part of the internet. Great to see people are so eager to help others! Hope to become a full-time member (and hopefully someone who contributes with answers rather than asks) in the future!


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums