;; niores - text adventure for Rejah ;; Nicholas McConnell [makecst *prefix* "nio-"] [makecst *group* "games"] ;; When running, don't forget there are things to check every move. [define niores [] "Run the game." [setv nio-dead false] [setv nio-numsaves 0] [setv nio-numcmds 0] [setv nio-section -1] [until nio-dead [unless [= nio-section nio-current-section] [nio-describe-section nio-current-section]] [setv nio-section nio-current-section] [nio-check-cases] [unless nio-dead [let [input] [setv input [nio-game-input]] [callf [second [assoc [varname [first input]] nio-verblist]] [rest input]] [incp nio-numcmds]]]]] ;; There are some cases to check at the beginning of every move. ;; They should not be checked after a misunderstood command. [define nio-check-cases [] [when [> nio-bridge 0] [decp nio-bridge] [when [= nio-bridge 0] [setp [nth bridge nio-section-objects] [list obj-fissure]]] [when [and [< nio-bridge 3] [member nio-current-section [list west-side-of-fissure east-side-of-fissure bridge]]] [print [nth nio-bridge '["The bridge stops shining and disappears." "The bridge is shining very faintly now." "The bridge now shines a little less brightly."]]] [when [and [= nio-bridge 0] [= nio-current-section bridge]] [print "You fall to the bottom of the fissure and crash!"] [nio-die "a fissure"]]]] [when nio-tv-on [when [= nio-current-section cottage] [print [first nio-tv]] [nio-sound [first nio-tv]]] [setv nio-tv [rconst [rest nio-tv] [first nio-tv]]]]] [define nio-game-input [] [let [ret] [while true [setv ret [nio-listify [raw-input ">"]]] [do-for [i nio-ignore] [nio-removep ret [string i]]] [if [and ret [assoc [varname [first ret]] nio-verblist]] [return ret] [if ret [print "I do not understand that."]]]]]] ;; Adventure situations here ;; If the user tries to quack by him/herself for the machine in the deep hole, ;; (s)he should understand (s)he can't do it. [define nio-quack [args] [print "You try to do this, but you happen to be bad at sounding just like a duck."] [nio-sound "You hear your voice say the word \"quack\"."]] ;; Say anything at all. This makes a sound. [define nio-say [args] [if [not args] [print "You didn't specify anything to say."] [print "Done."] [nio-sound [concat "You hear your voice say \"" [join (\space) args] "\"."]]]] ;; List every item in the player's inventory. ;; Special case for the container; we must also include what is in it. ;; Also, (the dictaphone buttons are separate objects) don't specify each button. [define nio-inven [args] [print "You currently have the following:"] [do-for [i nio-inventory] [when [and [!= i obj-red] [!= i obj-green]] [print " " [second [nth i nio-reg-src]]] [when [and [= i obj-container] nio-container] [print " This container contains:"] [do-for [j nio-container] [print " " [second [nth j nio-reg-src]]]]]]]] ;; Eating and drinking. [define nio-eat [args] [let [objnum] [when [isinteger [setv objnum [nio-objnum-from-args-std args]]] [if [not [member objnum nio-inventory]] [print "You don't have that."] [if [!= objnum obj-chip] [@n [print "You forcefully shove" [lowercase [second [nth objnum nio-reg-src]]] "down your throat and start choking."] [nio-die "choking"]] [print "Yum!"] [nio-removep nio-inventory obj-chip]]]]]] [define nio-quaff [args] [let [objnum] [when [isinteger [setv objnum [nio-objnum-from-args-std args]]] [if [and [= objnum obj-water] [nio-present obj-watercan] nio-filled] [setv objnum obj-watercan]] [if [not [nio-present objnum]] [print "I do not see that here."] [if [= objnum obj-vinegar] [@n [print "You taste the vinegar. Ughh!! This is not right for you."] [nio-die "drinking vinegar"]] [if [= objnum obj-water] [print "You try one sip of the water, but then you spit it out. You find the water to be very salty."] [if [= objnum obj-watercan] [if [not nio-filled] [print "There's no water in the can to drink."] [print "You drink the water from the can."] [setv nio-filled false]] [print "You can't drink that."]]]]]]]] ;; Take, drop and examine objects. Each of these has plenty of special cases. ;; (Plus, take should remove objects from the container, computer and chest) [define nio-take [args] [if [and args [member [first args] '["all" "entire" "everything"]]] [let [gotsome original] [setv gotsome false] [setv original [nth nio-current-section nio-section-objects]] [do-for [i original] [when [and [>= i 0] [!= i obj-red] [!= i obj-green] [!= i obj-special]] [prins [concat [second [nth i nio-reg-src]] ":"]] [nio-take-object i] [setv gotsome true]]] [unless gotsome [print "Nothing here to take."]]] [let [objnum] [when [isinteger [setv objnum [nio-objnum-from-args-std args]]] [nio-take-object objnum]]]]] [define nio-drop [args] [if [and args [member [first args] '["all" "entire" "everything"]]] [let [gotsome original] [setv gotsome false] [setv original nio-inventory] [do-for [i original] [when [and [!= i obj-red] [!= i obj-green]] [prins [concat [second [nth i nio-reg-src]] ":"]] [nio-drop-object i] [setv gotsome true]]] [unless gotsome [print "You have nothing to drop."]]] [let [objnum] [when [isinteger [setv objnum [nio-objnum-from-args-std args]]] [nio-drop-object objnum]]]]] [define nio-examine [args] [if [not args] [nio-describe-section [- nio-current-section]] [let [objnum] [when [isinteger [setv objnum [nio-objnum-from-args-std args]]] [if [not [nio-present objnum]] [print "I do not see that here."] [cond [[= objnum obj-watercan] [if [not nio-filled] [print "The watercan is empty. Tapping it with a fingernail would make a loud sound."] [print "The watercan is full of water."]]] [[and [= objnum obj-pipe] [= nio-current-section shed] nio-black] [print "In this light you can see some writing on the pipe. It says: \"For an explosive time, go to where the NIORES computer is.\""]] [[= objnum obj-book] [print [concat "The book says: \"The combination is " nio-combination "\"."]]] [[= objnum obj-rods] [if [not nio-wand] [@n [print "Searching deeply through the pile, you find a magic wand! You take it out of the pile."] [setv nio-wand true] [if [= [nio-inv-length] nio-max-objs] [nio-addp [nth west-side-of-fissure nio-section-objects] obj-wand] [nio-addp nio-inventory obj-wand]]] [print [randitem '[ "Searching deeply through the pile, you find a Pocky stick. This fails to hold your interest, so you put it back." "Searching deeply through the pile, you find a tree branch. You don't care much about that at all, so you put it back." "Searching deeply through the pile, you find a drinking straw. This fails to hold your interest, so you put it back." "Searching deeply through the pile, you find a hiking pole. You don't care much about that at all, so you put it back."]]]]] [[= objnum obj-cat] [if [not nio-asleep] [@n [print "The cat meows at you happily."] [nio-sound "You hear the sound of a cat meowing."]] [@n [print "The cat sleeps soundly, softly purring."] [nio-sound "You hear the blissful purrs of a cat."]]]] [true [let [desc] [if [< objnum 0] [setv desc [nth [abs objnum] nio-perm-desc]] [setv desc [nth objnum nio-reg-desc]]] [if [isstring desc] [print desc] [print "I see nothing special about that."]]]]]]]]]] ;; Fill the watercan with water. Water the flowers. [define nio-fill [args] [if [not [member nio-current-section [list patio cooking-room west-lake east-lake]]] [print "I see no way to fill things with water here."] [let [objnum] [when [isinteger [setv objnum [nio-objnum-from-args-std args]]] [if [not [member objnum nio-inventory]] [print "You don't have that."] [if [member objnum [list obj-container obj-pot]] [print "You wouldn't want to fill that object with water."] [if [!= objnum obj-watercan] [print "I don't know how to fill that with water."] [case nio-current-section [patio [print "You can't find how to squirt water from the hoses."]] [cooking-room [if nio-filled [print "The watercan is already full of water."] [print "You fill the watercan with warm water."] [setv nio-filled true]]] [nio-current-section [print "The water here is salty; you don't want to fill the watercan with it."]]]]]]]]]] [define nio-water [args] [let [objnum] [when [isinteger [setv objnum [nio-objnum-from-args-std args]]] [if [not [member objnum [nth nio-current-section nio-section-objects]]] [print "I do not see that here."] [if [!= objnum obj-flowers] [print "You can't water that."] [if [and [member obj-watercan nio-inventory] nio-filled] [if nio-flowers [print "The flowers are already watered! What's the point?"] [print "You water the flowers good as new."] [setv nio-flowers true] [setv nio-filled false] [nio-add-to-pchart 10]] [print "You have nothing with which to water them."]]]]]]] ;; Use the spade to dig for something. Then use it to bury things. [define nio-dig [args] [if [not [member obj-spade nio-inventory]] [print "You have nothing to dig with."] [if [not [nth nio-current-section nio-diggables]] [print "Digging here gets you nothing."] [print "I believe you found something."] [nio-extendp [nth nio-current-section nio-section-objects] [nth nio-current-section nio-diggables]] [setp [nth nio-current-section nio-diggables] '[]]]]] [define nio-bury [args] [if [not [member obj-spade nio-inventory]] [print "You have nothing to bury things with."] [let [objnum] [when [isinteger [setv objnum [nio-objnum-from-args-std args]]] [if [not [member objnum nio-inventory]] [print "You don't have that."] [if [member objnum [list obj-red obj-green]] [print "You can't just take a button off the dictaphone and bury it like that."] [print "Done."] [nio-removep nio-inventory objnum] [nio-addp [nth nio-current-section nio-diggables] objnum] [when [= objnum obj-dictaphone] [nio-removep nio-inventory obj-red] [nio-removep nio-inventory obj-green] [nio-addp [nth nio-current-section nio-diggables] obj-red] [nio-addp [nth nio-current-section nio-diggables] obj-green]]]]]]]] ;; Move around [define nio-north [args] [nio-move-dir north]] [define nio-south [args] [nio-move-dir south]] [define nio-east [args] [nio-move-dir east]] [define nio-west [args] [nio-move-dir west]] [define nio-northeast [args] [nio-move-dir northeast]] [define nio-southeast [args] [nio-move-dir southeast]] [define nio-northwest [args] [nio-move-dir northwest]] [define nio-southwest [args] [nio-move-dir southwest]] [define nio-up [args] [nio-move-dir up]] [define nio-down [args] [nio-move-dir down]] [define nio-in [args] [nio-move-dir in]] [define nio-out [args] [nio-move-dir out]] ;; Find the result on the Niores map. ;; If 99 is yielded, the move is special (like you can only go that way ;; under certain conditions). ;; If -1 is yielded, you simply can never go that way. ;; Otherwise, you simply end up in the yielded section. [define nio-move-dir [dir] [if [and [not [member nio-current-section nio-light-sections]] [not [member obj-lantern nio-inventory]]] [@n [print "You trip over a grue and fall into a pit and break every bone in your body!"] [nio-die "a grue"]] [let [newroom] [setv newroom [nth dir [nth nio-current-section niores-map]]] [case newroom [-1 [print "You cannot go that way."]] [99 [nio-special-move dir]] [newroom [setv nio-current-section newroom] [setv nio-section -1]]]]]] ;; Sections here are in index order. [define nio-special-move [dir] [case nio-current-section [west-side-of-fissure [if [> nio-bridge 0] [setv nio-current-section bridge] [print "You fall down the fissure and crash!"] [nio-die "a fissure"]]] [computer-section [if nio-hole [setv nio-current-section deep-hole] [print "You cannot go that way."]]] [shed [print "The hole is too high for you to jump up."]] [east-side-of-fissure [if [> nio-bridge 0] [setv nio-current-section bridge] [print "You fall down the fissure and crash!"] [nio-die "a fissure"]]] [west-lake [nio-swim '[]]] [east-lake [nio-swim '[]]] [robots-room [if [!= nio-breeze-level 3] [setv nio-current-section 23] [print "As you exit the building, you notice some wind blowing out of the door. Suddenly, the building breaks into a million tiny pieces. The wind blows you strongly until you smash on a wall, and you bleed to death."] [nio-die "being wind-smashed"]]] [slide [nio-slide '[]]] [deep-hole [if [not nio-quack-played] [print "You cannot go that way."] [if [= dir southwest] [setv nio-current-section ne-s-w-junction] [setv nio-current-section nw-s-e-junction]]]] [east-end [print "You must enter a three-digit combination code to enter this room."] [if [= [raw-input "Enter it here: "] nio-combination] [setv nio-current-section snack-room] [print "Sorry, that combination is incorrect."]]] [train-station [print "As soon as you board the train it immediately leaves the station. The ride seems bumpy at first, then gets smoother. Eventually, the train comes to a sudden stop, the doors open, and some force throws you out. The train speeds away."] [setv nio-current-section montgomery-station]] [treasure-room [print "You fall out from the opening. Fortunately, you quickly land somewhere safe."] [setv nio-current-section roof-of-shed]] [roof-of-shed [print "You fall down the hole and land on the ground of the shed. You stand up and brush yourself off."] [setv nio-current-section shed]]]] [define nio-go [args] [let [call] [if [not [and args [setv call [assoc [varname [first args]] nio-verblist]]]] [print "I don't understand where you want me to go."] [callf [second call] [rest args]]]]] [define nio-watch [args] [let [objnum] [when [isinteger [setv objnum [nio-objnum-from-args-std args]]] [if [not [nio-present objnum]] [print "I do not see that here."] [if [!= objnum obj-tv] [print "You cannot watch that."] [unless nio-tv-on [if [nio-present obj-remote] [nio-press '["remote"]] [print "There is nothing here that can turn it on."]]]]]]]] [define nio-sleep [args] [case nio-current-section [cottage [print "Isn't it good to just spend an hour lying on the sofa?"]] [nap-room [print "You take a quick nap."]] [bedroom [print "You fall asleep and eventually start dreaming. You dream that your parents ask you to get out of this bed. Then you get dressed and, after they leave, you go southwest where it's rocky. You find yourself burying something. After this, you immediately wake up."]] [nio-current-section [print "You try to go to sleep while standing up here, but can't seem to do it."]]]] ;; Waving wand [define nio-wave [args] [let [objnum] [when [isinteger [setv objnum [nio-objnum-from-args-std args]]] [if [not [member objnum nio-inventory]] [print "You don't have that."] [if [!= objnum obj-wand] [print "Waving" [lowercase [second [nth objnum nio-reg-src]]] "appears to have no effect."] [if [member nio-current-section [list west-side-of-fissure east-side-of-fissure bridge]] [@n [print "A bridge shines brightly over the fissure."] [setv nio-bridge 4]] [print "Nothing happens here."]]]]]]] ;; Swimming, sliding, moving slider, pressing buttons, remote and switch [define nio-swim [args] [if [and [!= nio-current-section west-lake] [!= nio-current-section east-lake]] [print "This is no place to swim!"] [if [not [member obj-life nio-inventory]] [@n [print "You dive in the water, and at first it feels really cold. Then you realize you get used to the fact that you've never really learned how to swim."] [nio-die "drowning"]] [if [= nio-current-section west-lake] [setv nio-current-section east-lake] [setv nio-current-section west-lake]]]]] ;; red button = record ;; green button = play [define nio-press [args] [let [objnum] [when [isinteger [setv objnum [nio-objnum-from-args-std args]]] [if [not [nio-present objnum]] [print "I do not see that here."] [case objnum [obj-red [if [not nio-dictaphone] [print "As soon as you release the button, it pops up."] [print "The dictaphone begins to hum softly."] [setv nio-dict-on true] [setv nio-recorded null]]] [obj-green [setv nio-dict-on false] [if [= nio-recorded null] [print "As soon as you release the button, it pops up."] [print nio-recorded] [nio-sound nio-recorded]]] [obj-remote [if [!= nio-current-section cottage] [print "Nothing happens here."] [setv nio-tv-on [not nio-tv-on]] [if nio-tv-on [print "The television turns on. An interesting story about ducks happens to be on TV."] [print "The television turns off, much to your relief."]]]] [obj-switch [setv nio-black [not nio-black]] [if nio-black [print "A black light is turned on in the shed."] [print "The black light turns off."]]] [objnum [print "You can't press that."]]]]]]] [define nio-move [args] [let [objnum] [when [isinteger [setv objnum [nio-objnum-from-args-std args]]] [if [not [member objnum [nth nio-current-section nio-section-objects]]] [print "I do not see that here."] [if [!= objnum obj-slider] [print "You can't slide that."] [if [not [and [> [length args] 1] [member [second args] '["right" "left"]]]] [print "You must indicate either right or left."] [if [= [second args] "right"] [incp nio-breeze-level] [decp nio-breeze-level]] [cond [[< nio-breeze-level 0] [print "The slider will go no further in that direction."] [setv nio-breeze-level 0]] [[> nio-breeze-level 3] [print "As the slider clicks into place, you are immediately smashed into the wall."] [nio-die "being wind-smashed"]] [true [print [nth nio-breeze-level '["The room has returned to normal room breeze." "It is quite refreshing in here. Your hair is being blown." "It is pretty windy in here. It is still comfortable." "It is now very windy in here. There is something very strong about this."]]]]] [nio-rip-apart]]]]]]] [define nio-slide [args] [if args [nio-move args] [if [!= nio-current-section slide] [print "This is no place to slide!"] [if nio-inventory [print "Naturally, you leave all your items here at the top, as you have fear of sliding down a slide with items in your hands."]] [nio-extendp [nth slide nio-section-objects] nio-inventory] [setv nio-inventory '[]] [print "You go down the slide, and it feels really wavy, just like at an amusement park. Eventually, you end up at the bottom of the slide, jump out, and land safely with the NIORES computer."] [setv nio-current-section computer-section] [nio-coin-interface]]]] [define nio-turn [args] [cond [[= nio-current-section cottage] [print "If you have the remote control to this television, you can 'press remote' to turn on or off the television."]] [[= nio-current-section computer-section] [print "You don't have to explicitly turn on the computer. Just use 'type'."]] [[= nio-current-section shed] [print "You need to press the switch in order to turn it on or off."]] [[nio-present obj-dictaphone] [print "You don't have to explicitly turn on the dictaphone."]] [true [print "I see nothing to turn on or off here."]]]] [define nio-open [args] [let [objnum] [when [isinteger [setv objnum [nio-objnum-from-args-std args]]] [if [not [nio-present objnum]] [print "I do not see that here."] [if [!= objnum obj-chest] [print "You do not have to open that object."] [if nio-opened [print "The treasure chest is already opened!"] [if [not nio-chest] [print "You open the treasure chest."] [print "You open the treasure chest, revealing some items."]] [setv nio-opened true]]]]]]] [define nio-close [args] [let [objnum] [when [isinteger [setv objnum [nio-objnum-from-args-std args]]] [if [not [nio-present objnum]] [print "I do not see that here."] [if [!= objnum obj-chest] [print "You do not have to close that object."] [if [not nio-opened] [print "The treasure chest is already closed!"] [print "You close the treasure chest."] [setv nio-opened false]]]]]]] [define nio-put [args] [let [obj1 obj2] [if [not args] [print "You must specify an object."] [if [= null [assoc [varname [first args]] nio-obj-refs] [assoc [varname [first args]] nio-obj-extras]] [print "I don't know what object that is."] [when [isinteger [setv obj1 [nio-objnum-from-args-std args]]] [when [= obj1 obj-water] [setv obj1 obj-watercan]] [if [not [member obj1 nio-inventory]] [print "You don't have that."] [if [member obj1 [list obj-red obj-green]] [print "I would advise you not to take a button off the dictaphone like that."] [while args [when [member [first args] '["in" "into" "on" "onto" "through"]] [delp [first args]] [break]] [delp [first args]]] [if [not args] [print "You must specify an indirect object."] [if [= null [assoc [varname [first args]] nio-obj-refs] [assoc [varname [first args]] nio-obj-extras]] [print "I don't know what indirect object that is."] [when [isinteger [setv obj2 [nio-objnum-from-args-std args]]] [if [not [nio-present obj2]] [print "That indirect object is not here."] [nio-put-objs obj1 obj2]]]]]]]]]]]] ;; nio-put-objs uses a cond statement [define nio-put-objs [obj1 obj2] [cond [[= obj2 obj-container] [if [not [member obj1 [list obj-coin obj-bill obj-pipe obj-tape obj-vinegar obj-soda obj-chip obj-blue obj-orange]]] [print "That won't fit in the container."] [print "Done."] [nio-removep nio-inventory obj1] [nio-addp nio-container obj1]]] [[and [= obj1 obj-tape] [= obj2 obj-dictaphone]] [print "The tape fits perfectly into the slot, and appears to be quite permanent."] [nio-removep nio-inventory obj-tape] [setv nio-dictaphone true]] [[and [= obj1 obj-watercan] [= obj2 obj-flowers]] [nio-water '["flowers"]]] [[= obj2 obj-rods] [if [!= obj1 obj-wand] [print "Such an object is hard to mix with the rods."] [print "Okay, if you say so."] [nio-removep nio-inventory obj-wand] [setv nio-wand false]]] [[= obj2 obj-computer] [if [not [member obj1 [list obj-bill obj-coin obj-chip]]] [print "That's not something you can put in the computer."] [print "Done. The computer's scanner perceives this object."] [nio-removep nio-inventory obj1] [nio-addp nio-computer obj1]]] [[= obj2 obj-water] [nio-removep nio-inventory obj1] [when [= obj1 obj-dictaphone] [nio-removep nio-inventory obj-red] [nio-removep nio-inventory obj-green]] [if [!= obj1 obj-life] [print "You drop the object in, and it sinks to the bottom."] [print "You drop the life vest on the water and it floats to the other side."] [if [= nio-current-section west-lake] [nio-addp [nth east-lake nio-section-objects] obj-life] [nio-addp [nth west-lake nio-section-objects] obj-life]]]] [[= obj2 obj-slide] [print "You put the object in the slide, and it slides down with a swooshing sound."] [nio-removep nio-inventory obj1] [nio-addp [nth computer-section nio-section-objects] obj1] [when [= obj1 obj-dictaphone] [nio-removep nio-inventory obj-red] [nio-removep nio-inventory obj-green] [nio-addp [nth computer-section nio-section-objects] obj-red] [nio-addp [nth computer-section nio-section-objects] obj-green]] [if [not [and [= obj1 obj-container] [member obj-soda nio-container] [member obj-vinegar nio-container]]] [print "Eventually you hear it land on the bottom safely."] [print "You hear it land with an explosive sound."] [nio-removep [nth computer-section nio-section-objects] obj-container] [setv nio-container '[]] [setv nio-hole true]]] [[= obj2 obj-train] [print "I advise you not to put stuff in the train without getting on the train yourself."]] [[= obj2 obj-chute] [if [not [member obj1 [list obj-bill obj-chip obj-coin obj-blue obj-orange]]] [print "That can't go into the chute."] [print "You hear the object slide down the chute and off into the distance."] [nio-removep nio-inventory obj1] [if [or [and [= obj1 obj-orange] [= nio-current-section orange-room]] [and [= obj1 obj-blue] [= nio-current-section blue-room]]] [nio-add-to-pchart 10] [if [member obj1 [list obj-blue obj-orange]] [nio-add-to-pchart 'bad]]]]] [[= obj2 obj-chest] [if [not nio-opened] [print "You'll have to open the treasure chest before putting in any items."] [print "Done."] [nio-removep nio-inventory obj1] [nio-addp nio-chest obj1] [when [= obj1 obj-dictaphone] [nio-removep nio-inventory obj-red] [nio-removep nio-inventory obj-green] [nio-addp nio-chest obj-red] [nio-addp nio-chest obj-green]]]] [[= obj2 obj-fissure] [if [= nio-bridge 0] [print "You drop the object into the fissure, without even hearing its landing."] [print "You drop the object on the bridge."]] [nio-removep nio-inventory obj1] [nio-addp [first nio-section-objects] obj1] [when [= obj1 obj-dictaphone] [nio-removep nio-inventory obj-red] [nio-removep nio-inventory obj-green] [nio-addp [first nio-section-objects] obj-red] [nio-addp [first nio-section-objects] obj-green]]] [true [print "I don't know how to put that object there; maybe you should try just dropping it."]]]] ;; Game commands here [define nio-quit [args] [nio-die '[]]] [define nio-die [reason] [print] [when reason [print "You are dead."]] [nio-score '[]] [nio-do-log reason] [setv nio-dead true]] [define nio-long [args] [setv nio-mode 'long]] [define nio-short [args] [setv nio-mode 'short]] [define nio-normal [args] [setv nio-mode 'normal]] ;; Here are all the game-dependent parameters. They are best defined here, ;; so the user can restart at any time (s)he wishes. [define nio-restart [args] [setv nio-mode 'normal] [setv nio-state 'niores] ;; There is a set of questions for the bill and another set for the coin. ;; Remember, only talk about situations you already know about. [setv nio-questions1 '[["What is the nearest whole dollar of the price of the spade?" "20" "twenty" "$20"] ["What is the last name of the logician involved in this game?" "smullyan"] ["What kind of flowers did you water?" "daisy" "daisies"] ["Who hand-crafted the lantern?" "geppetto"] ["Name either one of the two objects originally buried in the game." "coin" "shining" "tape"] ["What is the name of the first room you arrived in using the NIORES terminal?" "results"] ["What kind of switch was in the shed?" "bl" "black" "uv" "ultraviolet"] ]] [setv nio-questions2 '[["What animal would make the sound asked for in the deep hole?" "duck" "ducks"] ["What brand is the dictaphone?" "niores" "2000" "niores2000"] ["What kind of potato chip did you put in the computer?" "lays"] ["Name either one of the two objects you put in the container for the explosion." "baking" "soda" "vinegar"] ["What is the name of the station the train dropped you off at?" "montgomery"] ["Not counting the slide, how many chutes did you find?" "two" "2"] ]] [setv nio-inventory '[1]] [setv nio-section-objects [list [list obj-fissure] ;bridge [list obj-special obj-sofa obj-tv obj-container] ;cottage [list obj-can obj-life] ;patio [list obj-special obj-flowers] ;flower-garden [list obj-smullyan] ;art-room [list obj-spade] ;storage-section [list obj-fissure obj-rods] ;west-side-of-fissure [list obj-special obj-computer] ;computer-section [list obj-pot] ;cooking-room [list obj-special obj-switch] ;shed [list obj-fissure] ;east-side-of-fissure '[] ;results '[] ;fork [list obj-pipe] ;plumbers-room '[] ;ne-sw-rocky-road [list obj-bed] ;bedroom '[] ;hidden-shortcut '[] ;west-end-of-cave [list obj-water] ;west-lake [list obj-water] ;east-lake [list obj-vinegar obj-paper] ;east-end-of-cave [list obj-special obj-slider] ;breeze-area [list obj-remote] ;robots-room '[] '[] '[] '[] '[] ;desert '[] ;hill [list obj-special] ;nap-room [list obj-special obj-cat] ;play-room [list obj-slide] ;slide [list obj-special obj-bill] ;deep-hole '[] ;nw-s-e-junction '[] ;east-end [list obj-sign] ;sign-room [list obj-chip] ;snack-room '[] ;ne-s-w-junction [list obj-train] ;train-station [list obj-blue] ;south-end '[] ;montgomery-station '[] ;e-w-hallway-with-path-north '[] ;e-w-hallway-with-path-south [list obj-special obj-chest] ;treasure-room [list obj-chute] ;blue-room [list obj-chute] ;orange-room '[] ;roof-of-shed ]] [setv nio-visited '[16]] [setv nio-section -1] [setv nio-current-section 1] [setv nio-hidden true] [setv nio-tv-on false] [setv nio-tv '["A crescendo of music can be heard." "You can hear the sound of birds chirping in the sky." "\"Once in a faraway lake lived three ducks.\"" "\"These ducks liked spending time with themselves.\"" "\"One day they woke up hungry.\"" "\"Unfortunately, they couldn't find any food, so they started quacking ...\"" "The sound of ducks quacking can be heard." "\"No one came for a long time, so they quacked again ...\"" "The sound of ducks quacking can be heard." "\"Then, finally a fourth duck came and fed them.\"" "\"The ducks lived happily ever after. The End.\""]] [setv nio-bridge 0] [setv nio-wand false] [setv nio-diggables [list '[] '[] '[] '[] '[] '[] '[] '[] '[] '[] ;; 0-9 [list obj-coin] '[] '[] '[] [list obj-tape] ;; 10-14 '[] '[] '[] '[] '[] '[] '[] '[] '[] '[] ;; 15-24 '[] '[] '[] '[] '[] '[] '[] '[] '[] '[] ;; 25-34 '[] '[] '[] '[] '[] '[] '[] '[] '[] '[] '[] '[] ;; 35-46 ]] [setv nio-computer '[]] [setv nio-introduced false] [setv nio-quick-pass false] [setv nio-container '[]] [setv nio-chest [list obj-book obj-orange]] [setv nio-black false] [setv nio-hole false] [setv nio-quack-played false] [setv nio-filled false] [setv nio-flowers false] [setv nio-combination [display null [random 100 1000]]] [setv nio-opened false] [setv nio-dictaphone false] [setv nio-dict-on false] [setv nio-recorded null] [setv nio-point-chart '[]] [setv nio-breeze-level 0] [setv nio-asleep false]] ;; All such parameters need to be remembered in a saved game. ;; A saved game will be more hidden if it is encoded by rot13! ;; (a<>n, b<>o, c<>p, ... m<>z) [define nio-save [args] [if [not args] [print "You must specify a filename for the save."] [try-to null [@n [unless [member 'niores [file-dir]] [make-dir 'niores]] [savefile [concat "niores" [dir-joiner] [encode [first args] 'rot13] ".txt"] [encode [concat [nio-save-val "nio-mode"] [nio-save-val "nio-state"] [nio-save-val "nio-questions1"] [nio-save-val "nio-questions2"] [nio-save-val "nio-inventory"] [nio-save-val "nio-section-objects"] [nio-save-val "nio-visited"] [nio-save-val "nio-current-section"] [nio-save-val "nio-hidden"] [nio-save-val "nio-tv-on"] [nio-save-val "nio-tv"] [nio-save-val "nio-bridge"] [nio-save-val "nio-wand"] [nio-save-val "nio-diggables"] [nio-save-val "nio-computer"] [nio-save-val "nio-introduced"] [nio-save-val "nio-quick-pass"] [nio-save-val "nio-container"] [nio-save-val "nio-chest"] [nio-save-val "nio-black"] [nio-save-val "nio-hole"] [nio-save-val "nio-quack-played"] [nio-save-val "nio-filled"] [nio-save-val "nio-flowers"] [nio-save-val "nio-combination"] [nio-save-val "nio-opened"] [nio-save-val "nio-dictaphone"] [nio-save-val "nio-dict-on"] [nio-save-val "nio-recorded"] [nio-save-val "nio-point-chart"] [nio-save-val "nio-breeze-level"] [nio-save-val "nio-asleep"]] 'rot13]] [incp nio-numsaves]] [print "Error saving to file."]]]] [define nio-restore [args] [if [not args] [print "You must specify a filename for the restore."] [try-to null [@n [execute [decode [openfile [concat "niores" [dir-joiner] [decode [first args] 'rot13] ".txt"]] 'rot13]] [setv nio-section -1]] [print "Could not load restore file."]]]] [define nio-score [args] [print "You have scored" [nio-total-score] "out of a possible 65 points."] [if [= [nio-total-score] 65] [print "\nCongratulations. You have won. The quick password is 'knocuc'"]]] ;; This is the help file of the game. [define nio-help [args] [print "Welcome to Niores! I hope you are brave enough to complete this adventure. Tips: - You never have to explicitly stop a reecording; the recording stops after just one sound. Likewise, if you are carrying something like a life vest, you don't have to explicitly wear it in order to swim. - When you're carrying a lantern, it is always turned on. - You only earn points by doing intelliggent things. You must do these things without doing any bad things in the process. If your score becomes harmed for something bad you do, you probably will never receive credit again. - If you get lost in a desert, you can ddrop certain items in certain parts of the desert to make a map. - Directions in this game are: north, soouth, east, west, northeast, southeast, northwest, southwest, up, down, in, out. These can be abbreviated: n, s, e, w, ne, se, nw, sw, u, d, in, out. - There are no limits in the lengths of object names. - You can save a game with the 'save' coommand, and restore it with the 'restore' command. - If you fall down something, then in geeneral, you're unable to get back up. If you have any questions or concerns, please email me. My email address is nicholas.mcconnell9@gmail.com "]] [define nio-type [args] [if [!= nio-current-section computer-section] [print "There is nothing here for you to type on."] [case nio-computer ['[] [print "You type on the keyboard, but no reaction occurs."]] [[list obj-coin] [nio-coin-interface]] [[list obj-bill] [nio-bill-interface]] [[list obj-chip] [nio-chip-interface]] [nio-computer [print "You find a jumble of multiple softwares mixed together on the screen, which is turning out to be very confusing."]]]]] ;; Functions for the game's purposes ;; The number of objects in the inventory, not counting the buttons. [define nio-inv-length [] [length [place-for null nio-inventory [lambda [i] [and [!= i obj-red] [!= i obj-green]]]]]] ;; Process simplifier. Also, whenever only one cloth is available, "cloth" ;; returns this cloth. This actually also holds for the buttons on the ;; dictaphone. [define nio-objnum-from-args-std [wlist [terminal false]] [if [not wlist] [@ [unless terminal [print "You must specify an object."]]] [let [objnum choices avs cmessage] [if [!= null [setv objnum [assoc [varname [first wlist]] nio-obj-refs]]] [second objnum] [if [= null [setv objnum [assoc [varname [first wlist]] nio-obj-extras]]] [@ [unless terminal [print "I don't know what that is."]]] [setv objnum [rest objnum]] [setv choices [first objnum]] [setv avs [map ('nio-present) choices]] [setv cmessage [second objnum]] [if [not [member true avs]] [first choices] ;; If neither choice is present the first is not [if [> [count true avs] 1] [@ [unless terminal [print cmessage]]] [if [first avs] [first choices] [second choices]]]]]]]]] [define nio-save-val [var] [let [[val [eval [eval-string var]]]] [concat "[setv " var " '" [display null val] "]\n"]]] ;; Give long if user has been there, else short. ;; Always give long when in long mode, always give short when in short mode ;; (with a positive section number). ;; Also, give long if we were called with a negative section number. [define nio-describe-section [section] [if [and [not [member [abs section] nio-light-sections]] [not [member obj-lantern nio-inventory]]] [print "It's pitch dark. You're likely to be eaten by a grue."] [print [second [nth [abs section] nio-sections]]] [unless [and [!= nio-mode 'long] [> section 0] [or [= nio-mode 'short] [member [abs section] nio-visited]]] [print [first [nth [abs section] nio-sections]]]] [unless [member [abs section] nio-visited] [setv nio-visited [const [abs section] nio-visited]]] [let [src] [do-for [objnum [nth [abs section] nio-section-objects]] [unless nio-dead [if [= objnum obj-special] [nio-special-objects [abs section]] [if [>= objnum 0] [setv src [first [nth objnum nio-reg-src]]] [setv src null]] [when src [print src]] [when [and [= objnum obj-container] nio-container] [print "Inside the container you see:"] [do-for [x nio-container] [print " " [second [nth x nio-reg-src]]]]]]]]]]] ;; If there is a special object (99) in the section, that means the description is ;; specially dependent. All such cases are in the nio-special-objects function. [define nio-special-objects [section] [case section [flower-garden [if [not nio-flowers] [print "The flowers are bent down and motionless."] [print "The flowers are upright and happy."]]] [computer-section [when nio-computer [print "Inside the computer you see:"] [do-for [x nio-computer] [print " " [second [nth x nio-reg-src]]]]] [when nio-hole [print "There is a hole in the ground here."]]] [shed [when nio-black [if nio-inventory [print "The shed is lit by a black light, causing you and some of your objects to give off an eerie glow."] [print "The shed is lit by a black light, causing your body to give off an eerie glow."]]]] [breeze-area [print [nth nio-breeze-level '["It is normal room breeze in here." "It is quite refreshing in here." "It is pretty windy in here." "It is strongly windy in here." "You are dead now."]]] [nio-rip-apart]] [nap-room [when [member obj-cat [nth nio-current-section nio-section-objects]] [print "There is a kitty cat here in the room."] [if [not nio-asleep] [print "The cat is happily smiling at you."] [print "The cat is peacefully sleeping on a pillow."]]]] [play-room [nio-special-objects nap-room]] [deep-hole [if [not nio-quack-played] [print "There is a machine here with text on it reading: \"TO REVEAL MORE PATHS, THE SOUND OF DUCKS QUACKING MUST BE HEARD.\""] [print "There are paths to the southwest and southeast."]]] [treasure-room [if [not nio-opened] [print "The treasure chest is closed."] [if [not nio-chest] [print "The treasure chest is open, with nothing inside it."] [print "The treasure chest is open, and you can see inside it:"] [do-for [x nio-chest] [when [and [!= x obj-red] [!= x obj-green]] [print " " [second [nth x nio-reg-src]]] [when [and [= x obj-container] nio-container] [print " This container contains:"] [do-for [obj nio-container] [print " " [second [nth obj nio-reg-src]]]]]]]]]]]] ;; Blow any paper away when you are in the breeze area and it's strongly windy. [define nio-rip-apart [] [when [and [= nio-current-section breeze-area] [= nio-breeze-level 3]] [when [or [member obj-paper nio-inventory] [member obj-paper [nth breeze-area nio-section-objects]]] [print "You see the paper on the cube falling off and blowing away until there is no paper left. A pack of baking soda is uncovered!"] [if [member obj-paper nio-inventory] [@n [nio-removep nio-inventory obj-paper] [nio-addp nio-inventory obj-soda]] [nio-removep [nth breeze-area nio-section-objects] obj-paper] [nio-addp [nth breeze-area nio-section-objects] obj-soda]] [nio-add-to-pchart 10]] [when [or [member obj-bill nio-inventory] [member obj-bill [nth breeze-area nio-section-objects]]] [print "You see the dollar bill blowing away out of sight."] [nio-removep nio-inventory obj-bill] [nio-removep [nth breeze-area nio-section-objects] obj-bill]] [when [or [member obj-blue nio-inventory] [member obj-blue [nth breeze-area nio-section-objects]]] [print "You see the blue cloth blowing away out of sight."] [nio-removep nio-inventory obj-blue] [nio-removep [nth breeze-area nio-section-objects] obj-blue]] [when [or [member obj-orange nio-inventory] [member obj-orange [nth breeze-area nio-section-objects]]] [print "You see the orange cloth blowing away out of sight."] [nio-removep nio-inventory obj-orange] [nio-removep [nth breeze-area nio-section-objects] obj-orange]]]] [define nio-do-log [how] [unless [member 'niores [file-dir]] [make-dir 'niores]] [savefile [concat "niores" [dir-joiner] "last score.txt"] [concat [asc-time] " Niores last score:\nPlayer " [if [not how] [if [= [nio-total-score] 65] "won" "quit"] [concat "killed by " how [if [= [nio-total-score] 65] " (at winning score)" ""]]] " at " [nth 1 [nth nio-current-section nio-sections]] "\n\nPoints: " [nio-total-score] "\nSaves: " nio-numsaves "\nCommands: " nio-numcmds "\n"]]] [define nio-add-to-pchart [item] [let [oscore newscore] [setv oscore [nio-total-score]] [nio-addp nio-point-chart item] [setv newscore [nio-total-score]] [unless [= oscore newscore] [nio-score '[]]]]] [macro nio-addp [list item] `[setp :list [rconst :list :item]]] [macro nio-extendp [list items] `[setp :list [append :list :items]]] [macro nio-removep [list item] `[setp :list [remove :item :list]]] [define nio-total-score [] [if [not [member 'bad nio-point-chart]] [sum nio-point-chart] 0]] ;; Is an object visible here under any circumstances? ;; Doing this is useful, but tricky. Best to define a function for it. [define nio-present [objnum] [or [member objnum nio-inventory] [member objnum [nth nio-current-section nio-section-objects]] [and [member objnum nio-container] [nio-present obj-container]] [and [member objnum nio-computer] [nio-present obj-computer]] [and [member objnum nio-chest] nio-opened [nio-present obj-chest]]]] ;; Makes a sound effect in the game. This causes an effect on the dictaphone, the ;; deep hole, and the cat. [define nio-sound [sound] [when [and [nio-present obj-dictaphone] nio-dict-on] [print "As a habit, you naturally stop the recording after hearing the sound."] [setv nio-recorded sound] [setv nio-dict-on false]] [when [and [= nio-current-section deep-hole] [not nio-quack-played]] [if [!= sound "The sound of ducks quacking can be heard."] [print "The machine temporarily reads, \"THAT SOUND IS NOT ACCEPTED.\""] [print "The machine temporarily reads, \"THANK YOU\", and then goes black. Paths open to the southwest and southeast."] [setv nio-quack-played true] [nio-add-to-pchart 10]]] [when [and [!= sound "You hear the sound of a cat meowing."] [!= sound "You hear the blissful purrs of a cat."] [!= sound "The sound of a pot banging loudly is heard."] [member obj-cat [nth nio-current-section nio-section-objects]]] [if nio-asleep [print "The cat continues to sleep, undisturbed."] [print "The cat meows at what it hears."] [nio-sound "You hear the sound of a cat meowing."]]]] ;; Taking and dropping special functions [define nio-take-object [obj] [cond [[and [nio-present obj-container] [member obj nio-container]] [if [= [nio-inv-length] nio-max-objs] [print "You can't carry anymore items."] [print "You remove the object from the container."] [nio-addp nio-inventory obj] [nio-removep nio-container obj]]] [[and [nio-present obj-computer] [member obj nio-computer]] [if [= [nio-inv-length] nio-max-objs] [print "You can't carry anymore items."] [print "You take the object out of the computer."] [nio-addp nio-inventory obj] [nio-removep nio-computer obj]]] [[and [nio-present obj-chest] [member obj nio-chest] nio-opened [!= obj obj-red] [!= obj obj-green]] [if [= [nio-inv-length] nio-max-objs] [print "You can't carry anymore items."] [print "You take the object out of the treasure chest."] [nio-addp nio-inventory obj] [nio-removep nio-chest obj] [when [= obj obj-dictaphone] [nio-addp nio-inventory obj-red] [nio-addp nio-inventory obj-green] [nio-removep nio-chest obj-red] [nio-removep nio-chest obj-green]]]] [true [if [not [member obj [nth nio-current-section nio-section-objects]]] [print "I do not see that here."] [if [< obj 0] [print "You cannot take that."] [if [member obj [list obj-red obj-green]] [print "I would advise you not to take a button off the dictaphone like that."] [if [= [nio-inv-length] nio-max-objs] [print "You can't carry anymore items."] [nio-take-obj obj]]]]]]]] [define nio-take-obj [obj] [print "Taken."] [nio-removep [nth nio-current-section nio-section-objects] obj] [nio-addp nio-inventory obj] [when [= obj obj-dictaphone] [nio-removep [nth nio-current-section nio-section-objects] obj-red] [nio-removep [nth nio-current-section nio-section-objects] obj-green] [nio-addp nio-inventory obj-red] [nio-addp nio-inventory obj-green]] [when [and [= obj obj-pillow] nio-asleep] [print "The cat falls off the pillow and wakes up."] [setv nio-asleep false] [nio-add-to-pchart 'bad]]] [define nio-drop-object [obj] [if [not [member obj nio-inventory]] [print "You don't have that."] [if [member obj [list obj-red obj-green]] [print "I would advise you not to remove a button from the dictaphone like that."] [print "Done."] [nio-removep nio-inventory obj] [nio-addp [nth nio-current-section nio-section-objects] obj] [cond [[= obj obj-dictaphone] [nio-removep nio-inventory obj-red] [nio-removep nio-inventory obj-green] [nio-addp [nth nio-current-section nio-section-objects] obj-red] [nio-addp [nth nio-current-section nio-section-objects] obj-green]] [[and [= obj obj-pillow] [= nio-current-section nap-room] [member obj-cat [nth nap-room nio-section-objects]]] [print "The cat steps on the pillow and then goes to sleep."] [setv nio-asleep true] [nio-add-to-pchart 10]] [[= obj obj-pot] [print "The pot makes a loud noise."] [nio-sound "The sound of a pot banging loudly is heard."] [when [member nio-current-section [list nap-room play-room]] [let [oasleep] [setv oasleep nio-asleep] [setv nio-asleep false] [if [not [member obj-cat [nth nio-current-section nio-section-objects]]] [@n [print "A kitty cat comes here."] [when [and [= nio-current-section nap-room] [member obj-pillow [nth nap-room nio-section-objects]]] [print "The cat perceives the pillow, steps on and falls into a blissful sleep."] [setv nio-asleep true] [nio-add-to-pchart 10]]] [if oasleep [print "The cat wakes up suddenly."] [print "The cat looks up at you, eyes and ears alert."]]] [nio-removep [nth nap-room nio-section-objects] obj-cat] [nio-removep [nth play-room nio-section-objects] obj-cat] [nio-addp [nth nio-current-section nio-section-objects] obj-cat] [when [and oasleep [not nio-asleep]] [nio-add-to-pchart 'bad]]]]] [[and [= obj obj-container] [member obj-soda nio-container] [member obj-vinegar nio-container]] [print "As the container impacts the ground it explodes into a million pieces."] [nio-removep [nth nio-current-section nio-section-objects] obj-container] [setv nio-container '[]] [when [= nio-current-section computer-section] [print "This explosion breaks a hole in the ground."] [setv nio-hole true]]]]]]] ;; Listifying the user's input [define nio-listify [string [chars " \n\t,:;.!\""]] [let [broken ret] [setv broken true] [setv ret '[]] [do-for [c [lowercase string]] [if [member c chars] [setv broken true] [if broken [@n [setv ret [rconst ret [string c]]] [setv broken false]] [setp [last ret] [concat [last ret] [string c]]]]]] ret]] ;; Using the NIORES terminal [define nio-chip-interface [] [print] [if [= [nio-total-score] 65] [print "You have my questions already mastered. Why don't you try something different?\n"] [nio-score '[]] [if [< [nio-total-score] 60] [print "You cannot use this software until your score reaches 60.\n"] [print "Welcome to the final question set. You are a truly noble adventurer. Answer these questions to score the last 5 points!"] [let [wrong question] [setv wrong false] [while [and nio-questions2 [not wrong]] [setv question [randitem nio-questions2]] [print "Question:"] [print " " [first question]] [let [answer] [setv answer [nio-listify [raw-input "Answer:\n "]]] [if [and answer [member [first answer] [rest question]]] [@n [print "Correct!"] [nio-removep nio-questions2 question]] [print "Sorry, that answer is incorrect. Please try again later.\n"] [setv wrong true]]]]] [unless nio-questions2 [nio-addp nio-point-chart 5] [print "Congratulations! You now have all your points scored!\n"]]]]] [define nio-bill-interface [] [print] [if [not nio-questions1] [print "You have my questions already mastered. Why don't you try something different?\n"] [print "Hello, adventurer! Please answer each of the following questions I ask, and then a NIORES2000 dictaphone will be delivered."] [let [wrong question] [setv wrong false] [while [and nio-questions1 [not wrong]] [setv question [randitem nio-questions1]] [print "Q:" [first question]] [let [answer] [setv answer [nio-listify [raw-input "A: "]]] [if [and answer [member [first answer] [rest question]]] [@n [print "Correct!"] [nio-removep nio-questions1 question]] [print "Sorry, that answer is incorrect. Please try again later.\n"] [setv wrong true]]]]] [unless nio-questions1 [print "Congratulations! You answered all of the questions correctly! Thank you for using this software. You hear a thud from the hole down below."] [nio-extendp [nth deep-hole nio-section-objects] [list obj-dictaphone obj-red obj-green]]]]] [define nio-coin-interface [] [print] [unless nio-introduced [print "Welcome to the NIORES terminal! Type 'help' if you need help."] [setv nio-introduced true]] [setv nio-state 'terminal] [while [= nio-state 'terminal] [let [input call] [setv input [nio-listify [raw-input "? "] " \n\t"]] [when input [if [member (\=) [first input]] [let [index var expr] [setv index [find [first input] (\=)]] [setv var [subseq [first input] 0 index]] [setv expr [subseq [join (\space) input] [1+ index] null]] [nio-doassign var expr]] [if [not [setv call [assoc [varname [first input]] nio-terminal-verbs]]] [print [first input] ": not found, try help"] [callf [second call] [rest input]]]]]]]] [define nio-doassign [var expr] [if [and [not nio-quick-pass] [!= [raw-input "Enter quick pass: "] "knocuc"]] [print "Incorrect."] [setv nio-quick-pass true] [try-to null [eval [eval-string [concat "[setv " var " " expr "]"]]] [print "Invalid syntax."]]]] [define nio-term-exit [args] [print "\nYou step back from the computer."] [setv nio-state 'niores]] [define nio-term-rejah [args] [print [rejah]]] ;; echo has a special case for % ;; show the value of the variable [define nio-term-echo [args] [do-for [x args] [when [= [sref x 0] (\%)] [try-to null [setv x [display null [eval [varname [subseq x 1 null]]]]] [setv x ""]]] [prins x]] [print]] [define nio-term-inventory [args] [let [length] [setv length [nio-inv-length]] [when nio-hidden [incp length]] [format ('print) "(%d objects total)" length] [when nio-hidden [print " A pillow (hidden)"]] [do-for [x nio-inventory] [when [and [!= x obj-red] [!= x obj-green]] [print " " [second [nth x nio-reg-src]]]]]]] [define nio-term-pull [args] [if [not args] [print "Pull (terminal command)"] [let [objnum] [if [not [isinteger [setv objnum [nio-objnum-from-args-std args true]]]] [print "Pull command failed"] [if [and [= objnum obj-pillow] nio-hidden] [if [= [nio-inv-length] nio-max-objs] [print "Not enough inventory room"] [setv nio-hidden false] [nio-addp nio-inventory obj-pillow]] [print "Pull command failed"]]]]]] [define nio-term-goto [args] [if [not nio-inventory] [prins "\nEverything starts to blur for a moment."] [prins "\nEverything starts to blur for a moment, and you lose your items."]] [nio-extendp [nth computer-section nio-section-objects] nio-inventory] [setv nio-inventory '[]] [setv nio-current-section results] [nio-term-exit '[]]] ;; You can send objects! Isn't that crazy! [define nio-term-send [args] [if [not args] [print "Send (terminal command)"] [let [objnum] [if [not [isinteger [setv objnum [nio-objnum-from-args-std args true]]]] [print "No such object is available"] [if [or [not [member objnum nio-inventory]] [member objnum [list obj-red obj-green]]] [print "No such object is available"] [print "Sending" [lowercase [second [nth objnum nio-reg-src]]] "to Results ..."] [nio-removep nio-inventory objnum] [nio-addp [nth results nio-section-objects] objnum] [when [= objnum obj-dictaphone] [nio-removep nio-inventory obj-red] [nio-removep nio-inventory obj-green] [nio-addp [nth results nio-section-objects] obj-red] [nio-addp [nth results nio-section-objects] obj-green]] [print "Transfer completed successfully."]]]]]] [define nio-term-sections [args] [format ('print) "(%d sections total)" [length nio-visited]] [do-for [x nio-visited] [print " " [nth x nio-section-shorts]]]] [define nio-term-describe [args] [if [not args] [print "Describe (terminal command)"] [let [section] [setv section [index nio-section-shorts [first args]]] [if [not [member section nio-visited]] [print "No such section is available"] [print [first [nth section nio-sections]]]]]]] [define nio-term-help [args] [print "The following commands are accepted: describe - Input the name of any recognized section; its description will be shown. echo - Copies what you type, evaluating %-prefixed words. exit - Exits the NIORES terminal. goto - Sends you to Results without any items. help - Displays this help file. inventory - Displays every object in the player's inventory, including hidden ones. pull - Input a hidden object to reveal it in your inventory. rejah - Prints a Rejah statement. sections - Lists the names of the recognized sections from most recent to least recent. send - Input an object to send it to Results. But such an object is deleted from here after it is sent. "]] ;; Now set everything ;; NOTE: Every part of the desert looks identical, but you can drop items to ;; map it if you get lost. [setv nio-sections '[[ "You are standing on a very unsteady bridge that goes west and east." "Bridge" ;0 ] [ "You are in your cottage, where you live. Your television is here, as a free-time hobby, and so is the sofa that you sleep on at night. The front door faces east, to your patio." "Cottage" ;1 ] [ "You are now on your patio. You can see several hoses here, but you don't see where they are coming from. Your cottage is to the west, and a path to the northeast leads outside your patio." "Patio" ;2 ] [ "You are in a flower garden at the south end of an outdoor hallway. The hallway goes north, and you can also go back southwest. With you are a couple of flowers." "Flower Garden" ;3 ] [ "You are now in the middle of the outdoor hallway. The hallway continues to the north and south. There are many paintings here, but you happen to be familiar with only the one painting of Raymond Smullyan." "Art Room" ;4 ] [ "You are now where lots of tools are stored. The outdoor hallway continues to the north and south." "Storage Section" ;5 ] [ "You are at the north end of the outdoor hallway. To the east you can make out another hallway. But there is a fissure in between the hallways. There is a rather extraordinary pile of rods here." "West Side of Fissure" ;6 ] [ "You are at the south end of the hallway. The hallway goes north. Here you can see a NIORES computer on top of a thick pole. It has a small screen, but a whole keyboard. Cut into the pole is a scanner for the computer, and above this scanner reads, \"TO RUN SOFTWARE, INSERT TYPES OF MONEY\". Use the 'type' command to type on the computer." "Computer Section" ;7 ] [ "You are now where one generally cooks things. Unfortunately, most of the ingredients and tools have been removed. However, there are sources here where you can fill things with water. The hallway goes south, and you see a shed to the north, large enough for you to go in." "Cooking Room" ;8 ] [ "This is inside a shed. The walls here are made of sticks torn long ago. There are openings to the north and south. Curiously enough, there is a switch here on the wall labeled 'BL', and a hole in the ceiling." "Shed" ;9 ] [ "You are at the north end of an outdoor hallway. To the west you can make out another hallway. But there is a fissure in between the hallways. The ground here seems rather soft." "East Side of Fissure" ;10 ] [ "Outside a window you can see that you are at high altitude. There is a sign on the wall reading, 'Results'. The exit is to the east." "Results" ;11 ] [ "You are somewhere more rocky. Paths fork off to the northeast and southeast. You can also go back west." "Fork" ;12 ] [ "This is where a plumber normally works, but most of the supplies have been removed. The exit is to the northwest." "Plumber's Room" ;13 ] [ "You are on a rocky road that continues northeast and southwest." "NE/SW Rocky Road" ;14 ] [ "You are now in a nice bedroom. There is a twin bed here. Steps lead up and down from here, and you can also go back southwest." "Bedroom" ;15 ] [ "This is a well-hidden shortcut between hallways. To the southwest you can see a flower garden, and to the east you can see a cooking room." "Hidden Shortcut" ;16 ] [ "You are at the west end of a cave that goes east. Steps lead up out of sight." "West End of Cave" ;17 ] [ "You are at the west side of a lake that happens to exist inside the cave. The water here seems very deep. You can go back west." "West Lake" ;18 ] [ "You are now at the east side of the lake. The cave continues to the east." "East Lake" ;19 ] [ "This is the east end of the cave; the cave goes west." "East End of Cave" ;20 ] [ "You are now in what is known as a breeze area. There is nothing visible here besides a slider on the wall. A path goes east, and steps lead down from here." "Breeze Area" ;21 ] [ "This is a rather interesting room. There are a lot of robotic features here. A door leads to the northeast, and you can also go back west." "Robot's Room" ;22 ] [ "You are in a desert. A door to the southwest leads into a building." "Desert" ;23 ] [ "You are lost in the desert." "Desert" ;24 ] [ "You are lost in the desert." "Desert" ;25 ] [ "You are lost in the desert." "Desert" ;26 ] [ "You are lost in the desert." "Desert" ;27 ] [ "You have now reached the top of a hill. There is a door to the east, and a dry view is seen to the northwest." "Hill" ;28 ] [ "This is a room where animals normally take naps. Doors go to the east and west, and there is another room to the south." "Nap Room" ;29 ] [ "You are in a room where animals normally play. Unfortunately, there are now few toys in here. There is another room to the north." "Play Room" ;30 ] [ "Now you are standing at the top of a slide to the east. The slide is closed on top. There is a door to the west." "Slide" ;31 ] [ "You have gone underground. There are hard walls here, and you happen to be tall enough to get up out of the hole." "Deep Hole" ;32 ] [ "You are on a junction where paths go to the northwest, south and east." "NW/S/E Junction" ;33 ] [ "You are at the east end of a passage. There is a door to the east. You can go back west." "East End" ;34 ] [ "You are at the south end of a passage; you can go back to the north. There is a large sign here." "Sign Room" ;35 ] [ "There are lots of foods here, but there is a sign here that says not to touch them. This room is well-known to be a snack room because of this. The exit is to the west." "Snack Room" ;36 ] [ "You are on a junction where paths go to the northeast, south and west." "NE/S/W Junction" ;37 ] [ "You are at a train station. The exit is to the east. A train is visible here waiting for you." "Train Station" ;38 ] [ "You are at the south end of a passage. You can go back to the north." "South End" ;39 ] [ "You are in Montgomery station. A path leads to the east." "Montgomery Station" ;40 ] [ "You are in the middle of a hallway that goes east and west. A path goes to the north." "E/W Hallway with Path North" ;41 ] [ "You are in the middle of a hallway that goes east and west. A path goes to the south." "E/W Hallway with Path South" ;42 ] [ "You are in a treasure room at the east end of a hallway. There is an opening to the east without a visible ground, and a treasure chest here." "Treasure Room" ;43 ] [ "Curiously enough, the walls here are painted blue, and there is a blue chute on the ground here. The exit is to the south." "Blue Room" ;44 ] [ "Curiously enough, the walls here are painted orange, and there is an orange chute on the ground here. The exit is to the north." "Orange Room" ;45 ] [ "You are on the top of the roof of a shed, and above you can see the sky. There happens to be a hole on this roof." "Roof of Shed" ;46 ] ]] ;; Make a short room description, and change all spaces and slashes to dashes. ;; Remove all periods and apostrophes. [define nio-shorten [name] [let [[ret ""]] [do-for [c [lowercase name]] [setv ret [concat ret [cond [[member c " /"] "-"] [[member c ".'"] ""] [true [string c]]]]]] ret]] [setv nio-section-shorts '[]] [let [var] [do-times [n [length nio-sections]] [setv var [nio-shorten [second [nth n nio-sections]]]] [nio-addp nio-section-shorts var] [unless [defined [varname var] 'constant] [eval [list 'makecst [varname var] n]]]]] ;; If you're not in a light section and you don't have a lantern, it's too dark ;; for you to see. Which sections are light sections? [setv nio-light-sections '[0 1 2 3 4 5 6 7 8 9 10 11 16 23 24 25 26 27 28 31 46]] ;; You can't carry more than 8 objects at a time. [makecst nio-max-objs 12] ;; The Niores map lists, for each starting section and direction, the resulting ;; section. If such a section is -1, the user simply can't go there. If it is ;; 99, the move is special and depends on things. [makecst north 0] [makecst south 1] [makecst east 2] [makecst west 3] [makecst northeast 4] [makecst southeast 5] [makecst northwest 6] [makecst southwest 7] [makecst up 8] [makecst down 9] [makecst in 10] [makecst out 11] [setv niores-map '[ ;; n s e w ne se nw sw up dn in ot [-1 -1 10 6 -1 -1 -1 -1 -1 -1 -1 -1] ;0 [-1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 2] ;1 [-1 -1 -1 1 3 -1 -1 -1 -1 -1 1 3] ;2 [ 4 -1 -1 -1 16 -1 -1 2 -1 -1 2 -1] ;3 [ 5 3 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1] ;4 [ 6 4 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1] ;5 [-1 5 99 -1 -1 -1 -1 -1 -1 -1 -1 -1] ;6 [ 8 -1 -1 -1 -1 -1 -1 -1 -1 99 99 -1] ;7 [ 9 7 -1 16 -1 -1 -1 -1 -1 -1 -1 -1] ;8 [10 8 -1 -1 -1 -1 -1 -1 99 -1 -1 -1] ;9 [-1 9 -1 99 -1 -1 -1 -1 -1 -1 -1 -1] ;10 [-1 -1 12 -1 -1 -1 -1 -1 -1 -1 -1 -1] ;11 [-1 -1 -1 11 14 13 -1 -1 -1 -1 -1 -1] ;12 [-1 -1 -1 -1 -1 -1 12 -1 -1 -1 -1 -1] ;13 [-1 -1 -1 -1 15 -1 -1 12 -1 -1 -1 -1] ;14 [-1 -1 -1 -1 -1 -1 -1 14 21 17 -1 -1] ;15 [-1 -1 8 -1 -1 -1 -1 3 -1 -1 -1 -1] ;16 [-1 -1 18 -1 -1 -1 -1 -1 15 -1 -1 -1] ;17 [-1 -1 99 17 -1 -1 -1 -1 -1 -1 99 -1] ;18 [-1 -1 20 99 -1 -1 -1 -1 -1 -1 99 -1] ;19 [-1 -1 -1 19 -1 -1 -1 -1 -1 -1 -1 -1] ;20 [-1 -1 22 -1 -1 -1 -1 -1 -1 15 -1 -1] ;21 [-1 -1 -1 21 99 -1 -1 -1 -1 -1 -1 99] ;22 [23 23 23 23 23 23 23 22 24 23 22 -1] ;23 [24 24 24 24 24 24 25 24 -1 -1 -1 -1] ;24 [25 25 25 25 25 25 25 25 25 26 -1 -1] ;25 [26 26 27 26 26 26 26 26 -1 26 -1 -1] ;26 [27 27 27 27 27 28 23 27 27 -1 -1 -1] ;27 [-1 -1 29 -1 -1 -1 23 -1 -1 -1 -1 -1] ;28 [-1 30 31 28 -1 -1 -1 -1 -1 -1 -1 -1] ;29 [29 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1] ;30 [-1 -1 99 29 -1 -1 -1 -1 -1 99 99 -1] ;31 [-1 -1 -1 -1 -1 99 -1 99 7 -1 -1 7] ;32 [-1 35 34 -1 -1 -1 32 -1 -1 -1 -1 -1] ;33 [-1 -1 99 33 -1 -1 -1 -1 -1 -1 -1 -1] ;34 [33 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1] ;35 [-1 -1 -1 34 -1 -1 -1 -1 -1 -1 -1 -1] ;36 [-1 39 -1 38 32 -1 -1 -1 -1 -1 -1 -1] ;37 [-1 -1 37 -1 -1 -1 -1 -1 -1 -1 99 -1] ;38 [37 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1] ;39 [-1 -1 41 -1 -1 -1 -1 -1 -1 -1 -1 -1] ;40 [44 -1 42 40 -1 -1 -1 -1 -1 -1 -1 -1] ;41 [-1 45 43 41 -1 -1 -1 -1 -1 -1 -1 -1] ;42 [-1 -1 99 42 -1 -1 -1 -1 -1 99 -1 99] ;43 [-1 41 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1] ;44 [42 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1] ;45 [-1 -1 -1 -1 -1 -1 -1 -1 -1 99 99 -1] ;46 ;; n s e w ne se nw sw up dn in ot ]] ;; Same variable has references of /all/ the objects, both regular and permanent. ;; (Permanent objects are those with negative indices.) [setv nio-obj-refs '[[container 0] [jar 0] [glass 0] [lamp 1] [lantern 1] [can 2] [watercan 2] [lifevest 3] [life 3] [vest 3] [spade 4] [shovel 4] [digging 4] [wand 5] [rod 5] [coin 6] [shining 6] [pot 7] [metal 7] [pillow 8] [soft 8] [bill 9] [dollar 9] [dictaphone 10] [recorder 10] [niores2000 10] [pipe 11] [steel 11] [tape 12] [red 13] [record 13] [green 14] [play 14] [remote 15] [control 15] [vinegar 16] [soda 17] [baking 17] [chip 18] [lays 18] [potato 18] [blue 19] [orange 20] [book 21] [paper 22] [cube 22] [tv -1] [television -1] [sofa -2] [flower -3] [flowers -3] [painting -4] [art -4] [smullyan -4] [rs -4] [rods -5] [pile -5] [switch -6] [bl -6] [black -6] [uv -6] [ultraviolet -6] [computer -7] [niores -7] [scanner -7] [bed -8] [water -9] [lake -9] [slider -10] [breeze -10] [slide -11] [sign -12] [text -12] [train -13] [chute -14] [chest -15] [treasure -15] [fissure -16] [cliff -16] [pit -16] [kitten -17] [kitty -17] [cat -17]]] ;; Extra understood object names, which do not represent a particular object. ;; For example, there are two cloths, but "cloth" is understood, at least if there ;; is only one cloth here. [setv nio-obj-extras '[[button [13 14] "Which button do you mean, the red one or the green one?"] [cloth [19 20] "Which cloth do you mean, the blue one or the orange one?"]]] [let [var] [do-for [x nio-obj-refs] [setv var [concat "obj-" [string [first x]]]] [eval [list 'makecst [varname var] [second x]]]]] [makecst obj-special 99] ;; Make searches and descriptions of objects. [setv nio-reg-src '[["There is a glass container here." "A glass container"] ["There is a lantern nearby." "A lantern"] ["There is a water can here." "A water can"] ["There is a life vest here." "A life vest"] ["There is a digging spade here." "A spade"] ["A magic wand with a green star on the end lies nearby." "A wand"] ["There is a shining coin here." "A shining coin"] ["There is a metal pot here." "A metal pot"] ["There is a soft pillow here." "A pillow"] ["There is a dollar bill here." "A dollar bill"] ["There is a NIORES2000 dictaphone here." "A dictaphone"] ["There is a steel pipe here." "A steel pipe"] ["There is a small tape here." "A tape"] ["On this dictaphone are two buttons, one red and one green." "A red button"] [null "A green button"] ["There is a remote control here." "A remote control"] ["There is a pack of vinegar here." "Some vinegar"] ["There is a pack of baking soda here." "Some baking soda"] ["There is a potato chip here." "A potato chip"] ["There is a blue cloth here." "A blue cloth"] ["There is an orange cloth here." "An orange cloth"] ["There is a book here." "A book"] ["There is a large cube made out of paper here." "A paper cube"] ]] [setv nio-reg-desc '["It is just a plain glass container." "The lantern was hand-crafted by Geppetto." null "It floats on water feasibly." "It is a normal spade with a price tag on it reading $19.99." "The wand can be waved for magic." null "The pot would make a loud noise if you dropped it." "Made out of velvet, just the kind for sleeping on." null "A NIORES2000 recorder with a red button reading 'RECORD' and a green button reading 'PLAY'." null "It's the kind that goes in a tape recorder." null null "It looks just like the remote to your television!" null null "Just the kind of potato chip in a Lays chips bag. Smells tasty." null null null "Feels a little firm." ]] [setv nio-perm-desc '[null "A Magnavox Television. You don't seem to be able to find its power button, so you'll have to use the remote control to turn it on." "The sofa serves as your bed." "They look just like daisies to me." "The painting is of Raymond Smullyan, a famous logician and mathematician. You can't see who made it." null null null "It is a twin bed with a very firm mattress." null "The slider points to a breeze scale which has faded away a long time ago." "From up here you can't make out the bottom of the slide. But it would be interesting to try sliding down." "The sign says: \"You probably know that the computers here in Niores are run by types of money, like coins and bills. You probably do /not/ know that they accept also potato chips and crackers as money. So if you have a computer, try giving it a potato chip or cracker instead of eating the chip or cracker!\"" "It is a passenger train that's ready to go." null "It says 'Golden Treasures' on it." "It is a REALLY DEEP fissure." null ]] [setv nio-verblist '[[die nio-die] [help nio-help] [? nio-help] [save nio-save] [quit nio-quit] [restore nio-restore] [load nio-restore] [restart nio-restart] [long nio-long] [short nio-short] [normal nio-normal] [score nio-score] [points nio-score] [take nio-take] [get nio-take] [drop nio-drop] [throw nio-drop] [toss nio-drop] [examine nio-examine] [look nio-examine] [describe nio-examine] [read nio-examine] [x nio-examine] [l nio-examine] [r nio-examine] [inventory nio-inven] [items nio-inven] [i nio-inven] [say nio-say] [talk nio-say] [speak nio-say] [quack nio-quack] [fill nio-fill] [water nio-water] [plant nio-water] [go nio-go] [north nio-north] [south nio-south] [east nio-east] [west nio-west] [northeast nio-northeast] [southeast nio-southeast] [northwest nio-northwest] [southwest nio-southwest] [n nio-north] [s nio-south] [e nio-east] [w nio-west] [ne nio-northeast] [se nio-southeast] [nw nio-northwest] [sw nio-southwest] [up nio-up] [u nio-up] [down nio-down] [d nio-down] [in nio-in] [out nio-out] [on nio-in] [off nio-out] [enter nio-in] [exit nio-out] [board nio-in] [leave nio-out] [type nio-type] [put nio-put] [insert nio-put] [place nio-put] [press nio-press] [push nio-press] [switch nio-press] [flick nio-press] [slide nio-slide] [move nio-move] [sleep nio-sleep] [lie nio-sleep] [z nio-sleep] [doze nio-sleep] [nap nio-sleep] [eat nio-eat] [consume nio-eat] [devour nio-eat] [quaff nio-quaff] [drink nio-quaff] [wave nio-wave] [shake nio-wave] [circle nio-wave] [bury nio-bury] [dig nio-dig] [swim nio-swim] [dive nio-swim] [turn nio-turn] [close nio-close] [open nio-open] [watch nio-watch]]] [setv nio-terminal-verbs '[[sections nio-term-sections] [describe nio-term-describe] [inventory nio-term-inventory] [pull nio-term-pull] [help nio-term-help] [echo nio-term-echo] [send nio-term-send] [goto nio-term-goto] [exit nio-term-exit] [rejah nio-term-rejah]]] [nio-restart '[]] [setv nio-numcmds 0] [setv nio-numsaves 0] [setv nio-ignore '[the to at this that these those]] ;; Now run the program. [if [or [= *version* 1] [is-y-or-n "This is a later version of Rejah. Do you wish to play?"]] [niores] [print "Okay, that's fine."]] ;; niores ends here