Skip to reading
The Text Parser

12. Make a Help command with GDScript

Edition 0.86.3.4

Teach your adventure verbs and synonyms, add command input and connect typed instructions to real game actions.

Download PDFView PDF page

Add useful conditions#

For a room-specific hint, put If Current Room before the message. Send its True and False outputs to suitable responses. For a puzzle-specific hint, use If Variable and read clock_wound.

A help command is available project-wide unless your own script restricts it. A room test belongs in the handler; selecting a script in Text Parser does not bind that custom command to the room currently open in the editor.

You can use a normal PCA 3D GDScript record as the handler. This version does the same job as the visual example. Choose one method to begin with; you do not need both.

1. Open GDScript Designer and add a new script.

2. Set the ID to parser_help and the name to Parser Help.

3. Use the source below. Keep the base-class line if you replace the starter source.

4. Click Validate, then Apply Changes, and save the project.

5. Select this script for the custom help row in Text Parser.

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_command_context: Dictionary = {}) -> Variant:
    await SetVariable({"name": "help_used", "value": true})
    await ShowMessage({
        "text": "Try examine the timepiece or wind the clock.",
        "duration": 7.0
    })
    return true

Create help_used before using that version, or remove the SetVariable line if you only want a message. The leading underscore on _command_context tells GDScript that this example accepts the context without needing to read it.

Page 25 of 41Permalink
Go to page