1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
%mathpiper,title=""
roomsList := {};
//Kitchen.
kitchen := {};
kitchen["name"] := "kitchen";
kitchen["description"] :=
"
You are in a bright white room which has a sink on its
east wall which has cupboards above and below it. A table
with 4 chairs is in the center of the room and a refridgerator is
in its north west corner. Sitting on the table is
a piece of paper with writing on it.
There is an exit to the north.
";
roomsList["kitchen"] := kitchen;
//Dining room.
diningRoom := {};
diningRoom["name"] := "dining room";
diningRoom["description"] :=
"
You are in a large rectangular room with a high ceiling.
There is an oak table in the center of the room with 12
chairs around it. There is a crystal chandelier above
the table.
There is an exit to the south.
";
roomsList["dining room"] := diningRoom;
//Connect the rooms together.
kitchen["n"] := "dining room";
diningRoom["s"] := "kitchen";
%/mathpiper
%output,preserve="false"
Result: True
. %/output
%mathpiper
currentRoom := diningRoom;
While( True )
[
userInput := AskUser(currentRoom["description"] : Nl(): "Which direction (n,s,e,w,ne,se,sw,nw,q to quit)?");
If(userInput = "q", Break());
If(currentRoom[userInput] != Empty, currentRoom := roomsList[currentRoom[userInput]], TellUser("There is no exit in that direction."));
];
%/mathpiper
%output,preserve="false"
Result: True
. %/output
%mathpiper,title=""
ForEach(direction, {"n","s","e","w","ne","se","sw","nw"})
[
Echo(kitchen[direction]);
];
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
dining room
Empty
Empty
Empty
Empty
Empty
Empty
Empty
. %/output
|