Press "Enter" to skip to content

Input

The (cycling-link: ) macro

If you want to give players a possibility of choosing a value (from a specified list of values) which will be attributed to the variable, use the (cycling-link: ) macro.

With each click, players will be able to change the value of the $colour variable.

Example

=><=
choose your favourite colour:
(cycling-link: bind $colour, "blue", "red", "yellow", "green")

Result – you can test:

See more in documentation.

The (dropdown: ) macro

If you want to give players a possibility of choosing the value of a variable taken from a dropdown list, use the (dropdown: ) macro.

The START slip

How many angels have you noticed in the picture?
(dropdown: bind $picture, "1", "2", "3", "5")

[[Check your answers]]

The CHECK YOUR ANSWERS slip

{
    (if: $picture is "3")[You’re right! That’s the right answer.]
    (else:)[Wrong! (link-undo: "retreat")]
}

An editor view

Twine - View from the editor: the start card is connected with the card, check the answer.

Result – you can test:

How to solve problems with the CSS style? – use the code:

/* window of the list */
tw-expression[name="dropdown"] {
    background: white;
    color: black;
    padding: 10px;
}

/* window of the dropdown list */
tw-expression[name="dropdown"] option {
    background: white;
    color: black;
}

/* selected option */
tw-expression[name="dropdown"] option:checked {
    background: grey; 
}

tw-expression[name="dropdown"] select {
    border: none;
    padding: 10px;
}

tw-expression[name="dropdown"] select:focus {
    outline: none !important;
}

See more in documentation.

Frequent error

Please, remember that 3 (type: number) is not “3” (type: string)

How to solve this problem?

Let’s assume that the player has selected “3” (type: string) from the list. If you want to check whether the player has chosen the right answer, you should use the IF instruction.

Way no. 1:
(if: $picture is "3")[You’re right! That’s the right answer.]

Way no. 2:
(set: $picture to (num: $picture))
(if: $picture is 3)[You’re right! That’s the right answer.]

Way no. 3:
(if: (num: $picture) is 3)[You’re right! That’s the right answer.]

Converting number into string: (text: $number)
Converting string into number: (num: $text)

Additionally:
Converting into lowercase text: (lowercase: $text)
Converting into uppercase text: (uppercase: $text)
The first letter must be lowercase: (lowerfirst: $text)
The first letter must be uppercase: (upperfirst: $text)

The (prompt:) macro

Example 1

A box to be completed without a default value.

(set: $name to (prompt: "Enter your name:", ""))
Hello $name. It’s time for an adventure!
Result: Enter your name: ... OK / Cancel

Example 2

A box to be completed with a default value “Player”.

(set: $name to (prompt: "Enter your name:", "Player"))
Hello $name. It’s time for an adventure!
Result: Enter your name: Player - OK / Cancel

Example 3

If players decide to enter their names, they must click the “enter” link. Then, their names entered previously will appear on the next slips.

If players do not decide to enter their names and they do not click the “enter” link ($name=""), then the value “Player” will be set for the $name variable on the next slips.

The START slip

{
    Do you want to enter your name?
    (click: "enter")
    [(set: $name to (prompt: "Enter your name", ""))]
}


[[Next]]

The NEXT slip

(if: $name is "")[(set: $name to "Player")]
Hello $name. It’s time for an adventure! 

An editor view

View from the editor: the start card is connected with the next card

Result – you can test:

The (confirm: ) macro

If you just want players to enter the OK (true) answer or the CANCEL (false) answer, please, use the (confirm: ) macro.

Example

(set: $decision to (confirm: "Do you want to enter the building?"))
{
    (if: $decision)[You notice a beautiful [[picture]].]
    (else:)[Well – you have missed a lot. [[next]]]
}

An editor view

Twine - View from the editor. The start card is connected with the cards: picture and next

Result – you can test:

The (alert: ) macro

If you just want to display a message to players, use the (alert: ) macro.

Example

(alert: "Remember, it’s a good idea to use a flashlight in the darkness.")

Result

Result: Remember, it’s a good idea to use a flashlight in the darkness. OK

More information

Font Resize
Contrast