Skip to reading
Text & Sierra-Style Adventures

A9. Controller source: lines 281-315

Edition 0.86.3.4

Build a complete text or graphical parser adventure with typed commands, inventory puzzles and press-to-walk controls.

Download PDFView PDF page

Grammar routing from verbs and noun phrases.

Code example
            elif not bool(Runtime.variables.ta_fuse_fitted):
                reply("The switch clicks. Nothing happens. "
                    + "The fuse holder is empty.")
            else:
                award("ta_signal_sent", 3)
                reply("The dial glows. A voice answers through "
                    + "the rain. Your warning has reached the "
                    + "next station. THE END. Score: 10 of 10.")
            return
    if command.begins_with("ask "):
        if command == "ask morgan about radio" and present("morgan"):
            reply("Morgan says, 'The spare fuse is in the cabin. "
                + "Fit it, then turn the radio on.'")
        else:
            reply("Try ASK MARA ABOUT RADIO while in the yard.")
        return
    if command.begins_with("pick up "):
        command = "take " + command.substr(8)
    var words: PackedStringArray = command.split(" ", false)
    var verb: String = str(VERBS.get(words[0], ""))
    if verb.is_empty():
        reply("I don't know that command. Type HELP for examples.")
        return
    var target: String = " ".join(words.slice(1))
    if target.begins_with("at ") or target.begins_with("to "):
        target = target.substr(3)
    if verb == "use" and target.contains(" on "):
        var pair: PackedStringArray = target.split(" on ")
        if pair.size() != 2:
            reply("Use one item on one target at a time.")
            return
        use_pair(str(NOUNS.get(pair[0], "")),
            str(NOUNS.get(pair[1], "")))
        return
    var noun: String = str(NOUNS.get(target, ""))

Continue directly with the next source block.

Page 62 of 68Permalink
Go to page