// The Hollow Cottage // Chapter 7 const cottageName = "The Hollow Cottage" function showInventory(items) writeln("You are carrying:") for each item in items writeln("- " + item) end for end function writeln("You are standing outside " + cottageName + ".") var playerName = input("What is your name, traveler? ") writeln("Welcome, " + playerName + ".") var tries = 0 var solved = false while tries < 3 and not solved tries = tries + 1 var answer = input("There is a riddle carved into the door. It asks: what has keys but no locks? ") if lower(trim(answer)) == "piano" then writeln("The door swings open. You step inside.") solved = true else writeln("Nothing happens.") end if end while if not solved then writeln("The door refuses to budge. You'll have to find another way in.") else writeln("The cottage is dusty but intact.") var inventory = array() append(inventory, "rusty key") append(inventory, "half-burned candle") writeln("On the floor, you notice a rusty key and a half-burned candle.") var command = input("What do you do? ") var words = split(lower(trim(command)), " ") var verb = words[0] if verb == "take" then showInventory(inventory) else if verb == "look" then writeln("A small cottage, one room, one door out.") else writeln("Nothing happens.") end if end if