Skip to reading
Text & Sierra-Style Adventures

A8. Controller source: lines 246-280

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

Save, restore, restart and radio commands.

Code example
            var names: PackedStringArray = []
            for item: String in Runtime.inventory:
                names.append(Runtime.project.get_inventory(item)
                    .get("name", item))
            reply("You are carrying: " + (
                ", ".join(names) if not names.is_empty()
                else "nothing" ) + ".")
            return
        "north", "n", "go north", "south", "s", "go south":
            await travel(command)
            return
        "save", "save game":
            var ok: bool = Runtime.save_game(1, "The Last Signal")
            reply("Saved in slot 1." if ok else "Save failed.")
            return
        "restore", "restore game", "load", "load game":
            if Runtime.save_slot_exists(1):
                Runtime.call_deferred("load_game", 1)
            else:
                reply("No save in slot 1.")
            return
        "restart":
            confirm_restart = true
            reply("Type RESTART YES to begin again. "
                + "Your saved game will remain.")
            return
        "restart yes":
            if confirm_restart:
                Runtime.call_deferred("start_new_game")
            else:
                reply("Type RESTART first.")
            return
        "turn on radio", "switch on radio":
            if Runtime.scene_id != "cabin":
                reply("The radio is inside the cabin.")

Continue directly with the next source block.

Page 61 of 68Permalink
Go to page