Skip to reading
Text & Sierra-Style Adventures

A10. Controller source: lines 316-350

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

Object descriptions, pickups, drops and the door.

Code example
    if noun.is_empty():
        reply("Please name one thing: for example, LOOK KEY.")
    elif not present(noun):
        reply("You can't see that here.")
    else:
        act(verb, noun)
Code example
func act(verb: String, noun: String) -> void:
    if verb in ["look", "read"]:
        var descriptions: Dictionary = {
            "key":"A small brass key. It should fit the cabin door.",
            "fuse":"A spare fuse, just right for the transmitter.",
            "door":"A locked wooden door leading north.",
            "note":"The note reads: 'Morgan has left the key on "
                + "the bench. Spare fuse inside. Send the warning.'",
            "radio":"An old transmitter with an empty fuse holder.",
            "morgan":"Morgan, the station operator, looks worried."
        }
        if noun == "door" and bool(Runtime.variables.ta_unlocked):
            reply("The cabin door is unlocked.")
        elif noun == "radio" and bool(Runtime.variables.ta_fuse_fitted):
            reply("The fuse is fitted. The radio is ready to switch on.")
        else:
            reply(str(descriptions[noun]))
    elif verb in ["take", "drop"] and noun in ["key", "fuse"]:
        var item_id: String = "brass_key" if noun == "key" else "fuse"
        if verb == "take":
            if HasInventory(item_id):
                reply("You already have it.")
                return
            Runtime.add_inventory(item_id)
            Runtime.variables["ta_" + noun + "_room"] = "carried"
            award("ta_found_" + noun, 1)
            reply("Taken.")
        elif HasInventory(item_id):

Continue directly with the next source block.

Page 63 of 68Permalink
Go to page