User Tools

Site Tools


Sidebar

Passage markup

basics

coding

extra

list

section

whitespace

Macros

basics

colour

data structure

date and time

game state

live

maths

number

revision

saving

showing and hiding

string

styling

url

deprecated

Types of data

Special keywords

Special passage tags

harlowe:prompt

(prompt: String, String) → String

When this macro is evaluated, a browser pop-up dialog box is shown with the first string displayed, a text entry box containing the second string (as a default value), and an “OK” button to submit. When it is submitted, it evaluates to the string in the text entry box.

Example usage:

(set: $name to (prompt: "Your name, please:", "Frances Spayne"))

Details:

This is essentially identical to the Javascript prompt() function in purpose and ability. You can use it to obtain a string value from the player directly, such as a name for the main character. But, be aware that as the box uses the player's operating system and browser's styling, it may clash visually with the design of your story.

When the dialog is on-screen, the entire game is essentially “paused” - no further computations are performed until it is dismissed.

See also:

harlowe/prompt.txt · Last modified: 2017/10/10 00:39 (external edit)