13. Turn an answer into a small puzzle
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.
| Choice in this recipe | Reason |
|---|---|
| Trim outside spaces | A stray space at the end should not spoil the answer. |
| Convert to uppercase | clock, Clock and CLOCK can mean the same answer. |
| Check a Boolean first | Prevents the reward being given repeatedly. |
| Disable the solved button | Makes 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.
