Skip to reading
Text & Sierra-Style Adventures

A7. Controller source: lines 211-245

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

Room descriptions and the first command branches.

Code example
func present(noun: String) -> bool:
    if noun in ["key", "fuse"]:
        var place: String = str(Runtime.variables.get(
            "ta_" + noun + "_room", ""))
        return place == Runtime.scene_id or place == "carried"
    if noun in ["door", "note", "morgan"]:
        return Runtime.scene_id == "lab"
    return noun == "radio" and Runtime.scene_id == "cabin"
Code example
func describe_room() -> String:
    var loose: String = ""
    for item: String in ["key", "fuse"]:
        if Runtime.variables.get("ta_" + item + "_room") == Runtime.scene_id:
            loose += " There is a " + item + " here."
    if Runtime.scene_id == "lab":
        return ("STATION YARD\nRain drums on the old signal cabin. "
            + "A note is pinned beside its door. Morgan waits by "
            + "the bench. The cabin is north." + loose)
    return ("SIGNAL CABIN\nThe transmitter waits on the table. "
        + ("Its fuse is fitted. " if Runtime.variables.ta_fuse_fitted
        else "Its fuse holder is empty. ")
        + "The yard is south." + loose)
Code example
func execute_command(command: String) -> void:
    match command:
        "help":
            reply("Try LOOK, LOOK KEY, TAKE KEY, INVENTORY, "
                + "USE KEY ON DOOR, OPEN DOOR, NORTH, SOUTH, "
                + "TALK TO MARA or ASK MARA ABOUT RADIO. "
                + "SAVE uses slot 1. RESTORE loads it.")
            return
        "look", "l", "look around":
            reply(describe_room())
            return
        "inventory", "i":

Continue directly with the next source block.

Page 60 of 68Permalink
Go to page