Skip to reading
Buttons, Labels & Text Boxes

13. Turn an answer into a small puzzle

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView illustrations

Add answer_box and a Check answer button. Use the same ordinary single-line setup as name_box, with Placeholder set to Type CLOCK. The button will run a second GDScript record called check_answer.

1. Define register_open as Boolean false and score as Number 0.

2. Give the feedback label the text $$feedback.

3. Create the check_answer script from the next page and validate/apply it.

4. Set Check answer's Click behavior to run-visual-script, Target check_answer.

5. Try a wrong word, then CLOCK. Check the feedback, score and disabled button.

Figure 22. A wrong answer produces feedback without awarding the reward. The entered word remains in the box for editing.

Source table from 13. Turn an answer into a small puzzle, page 29
Choice in this recipeReason
Trim outside spacesA stray space at the end should not spoil the answer.
Convert to uppercaseclock, Clock and CLOCK can mean the same answer.
Check a Boolean firstPrevents the reward being given repeatedly.
Disable the solved buttonMakes the completed state clear to the player.

The comparison rule belongs to the script. Change it if your puzzle needs exact capitalization, several acceptable answers or a different response to a blank field.

Page 29 of 46Permalink
Go to page