0 votes
by (510 points)
I want to be able to show the prompt again if nothing is typed so that sentences are actually complete.

1 Answer

+1 vote
by (910 points)
selected by
 
Best answer

You could always set a default value for the string, and check if the string has been changed. If the string is still set to the default after running the code, refuse to continue until something is entered. So, for example, you would put this just somewhere in the passage, so that it runs as soon as the passage is loaded:

(set: $yourstring to "default")

Then, when the prompt is launched (such as by clicking a link, or however you're handling it):

(if: $yourstring is "default")[(set: $yourstring to (prompt: "Define the string:", "not default"))]
(if: $yourstring is "default")[Dude just type something in the box]
(else:)[Text continuing the story]

I'm pretty sure the rest of the code won't execute until after the prompt window is closed, so this should allow you to prompt the player to input something, check whether they did, and continue or refuse to continue depending on whether they entered something. If they refused, they can just click on the link to run the code again.

by (159k points)

There are a couple of potential situations in which the above solution won't work:

1. If the Reader selects the "Cancel" button then the (prompt:) macro will return an Empty-String value.

2. If the Reader clears the supplied default value then selects the "Ok" button then the macro will also return an Empty-String value.

I would suggest changing the second (if:) macro to check for an Empty-String value like so...

(if: $yourstring is "default" or $yourstring is "")[Dude just type something in the box]\
(else:)[Text continuing the story]

 

...