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
|
%mathpiper,title=""
//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.
";
//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.
";
//Connect the rooms together.
kitchen["n"] := diningRoom;
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 := currentRoom[userInput], TellUser("There is no exit in that direction."));
];
%/mathpiper
%output,preserve="false"
Result: True
. %/output
|