Skip to reading
Progress Bars, Hints & Journals

13. Make a Give one more hint Button

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 PDF page

Create a GDScript record with ID next_hint. This version advances the machine topic by one answer each time and stops at three:

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_context: Dictionary = {}) -> Variant:
    var values: Dictionary = Runtime.get("variables") as Dictionary
    var unlocked: Dictionary = values.get("hintsUnlocked", {}) as Dictionary
    var next_answer: int = mini(3, int(unlocked.get("machine", 0)) + 1)
    await UnlockHint({
        "topicId": "machine",
        "answerNumber": next_answer
    })
    return true

1. Apply Changes in the script editor.

2. Add a Button called Give one more hint.

3. In Events, set Click to run-visual-script and choose next_hint as the target.

4. Test repeated clicks in gameplay. Reopen the topic after each refresh to read the available answers.

hintsUnlocked stores the highest unlocked answer number for each topic. If machine is absent, the script treats the count as zero. Change both machine references for another topic, and replace 3 with that topic’s actual number of answers.

This Button deliberately gives help every time it is pressed. If you want a confirmation before revealing the final solution, add that choice to the surrounding GUI or script.

Page 23 of 53Permalink
Go to page