-- ALAN etude featuring Floyd from Planetfall. -- Mostly, this demonstrates how to construct fairly elaborate actors; -- it also uses some other basic ALAN techniques. -- -- Written by Mark Sachs (mbs110@psuvm.psu.edu) over a long span of time -- concluding on October 13, 1993. -- -- ALAN 2.4 is required to compile this properly. One other note: ALAN -- does not provide a way to escape out and produce a quotation mark ". -- Rather than put in double apostrophes, I've simulated them on my -- Amiga with the key sequence ALT-K SPACE. Other computers probably -- don't have this, so the faux quote mark ¨ will look kind of weird. -- -- If you do have ALAN and have written adventures or even just etudes -- like this one, don't be shy! Upload them to the IF-archive at once! -- Your act of kindness will be most appreciated. OBJECT ATTRIBUTES closed. NOT locked. NOT openable. NOT takable. NOT slidable. NOT a_card. NOT an_actor. weight 0. SYNONYMS east = e. west = w. z = 'wait'. i = 'inventory'. get = take. run = slide. thru = through. floyd = robot. SYNTAX 'look' = 'look'. 'quit' = 'quit'. 'wait' = 'wait'. 'score' = 'score'. take_inv = 'inventory'. take = take (obj) *. drop = drop (obj) *. turn_on = turn on (obj). turn_off = turn off (obj). play_with = play with (obj). talk_to = talk 'to' (obj). give = 'give' (obj) 'to' (recip). slide_thru = 'slide' (obj) 'through' (ind). VERB 'look' DOES LOOK. END VERB. VERB 'quit' DOES IF Floyd HERE THEN "Floyd grins impishly. ¨Giving up, huh?¨$n" END IF. "$nGoodbye!" SCORE. "$n" QUIT. END VERB. VERB 'wait' DOES "Time passes..." END VERB. VERB 'score' DOES SCORE. END VERB. VERB take_inv DOES LIST inventory. END VERB. VERB open CHECK OBJECT IS openable ELSE "That would be a neat trick, opening the $o..." AND OBJECT IS closed ELSE "The $o is already open." AND OBJECT IS NOT locked ELSE "It isn't opening." DOES MAKE OBJECT NOT closed. "The $o opens." END VERB. VERB close CHECK OBJECT IS openable ELSE "You can't even open the $o, much less close it." AND OBJECT IS NOT closed ELSE "It _is_ closed!" DOES MAKE OBJECT closed. "You close the $o." END VERB. VERB take CHECK OBJECT IS takable ELSE "You can't take that." AND OBJECT NOT IN inventory ELSE "You did already, remember?" DOES IF OBJECT IN Floyd THEN MAKE Floyd NOT carrying. END IF. LOCATE OBJECT IN inventory. "Taken." END VERB. VERB drop CHECK OBJECT IN inventory ELSE "But you're not carrying that!" DOES LOCATE OBJECT HERE. "Dropped." END VERB. VERB read DOES "That isn't something you can read." END VERB. VERB examine DOES "You see nothing special." END VERB. VERB give CHECK obj IN inventory ELSE "You don't have that." AND recip IS an_actor ELSE "You can't give a $o to a $2!" END VERB. VERB play_with DOES "You fiddle with the $o for a while. Gosh, that was fun." END VERB. VERB talk_to DOES "Talking to a $o is usually taken as a sign of impending mental collapse." END VERB. VERB turn_on DOES "You can't turn that on." END VERB. VERB turn_off DOES "You can't turn that off." END VERB. VERB slide_thru CHECK obj IN inventory ELSE "You don't have that." AND ind IS slidable ELSE "I don't think so." AND obj IS a_card ELSE "That makes no sense!" END VERB. -- THE WORLD and all its contents. -- First, redefine the inventory for weight limits etc. -- How this works is straightforward: if a LIMIT is violated, the object -- simply does not budge. If you try to take something, it stays on the -- ground; if something is LOCATEd into your inventory, it doesn't move. -- This leads to problems, needless to say, when stuff is being LOCATEd -- in from Limbo... -- Three work-arounds: first, write your own limit system. -- Second, avoid teleporting things directly into the inventory. Third, -- put in some additional code for the occasions when you -- really want to port things in: teleport an object first to the room, -- then to the inventory -- so if a check fails the object remains in the -- room, at least. A few appropriate failure messages here give the impression -- that the player tried to take the object, but failed. This last method is -- what I use here. CONTAINER inventory LIMITS COUNT 3 THEN "$nYou can't juggle any more objects; it slips from your hands." weight 20 THEN "$nYou can't carry that much weight. It tumbles to the ground." HEADER "You are carrying:" ELSE "You are empty-handed." END CONTAINER. -- Where stuff goes when we want to hide it from the player. LOCATION limbo END LOCATION. -- Starting room, and a few bits and pieces to play with. LOCATION waiting_room NAME Waiting Room DESCRIPTION "You're standing in a nondescript, slightly dingy waiting room with white painted walls and a tile floor. A corridor leads south into the Robot Shop." DESCRIBE scenic_door. DESCRIBE scenic_slot. "$n" EXIT e, out TO scenic_overlook CHECK scenic_door IS NOT closed ELSE "Thump! You bang your nose against the closed door as you attempt this feat." DOES "You step through the door and are stunned by the sight that unfolds." SCORE 5. END EXIT. EXIT s TO robot_shop. END LOCATION. OBJECT scenic_door NAME white door AT waiting_room IS closed. IS openable. IS locked. DESCRIPTION "An ordinary white door leads east." IF scenic_door IS closed THEN "It's closed." ELSE "It's wide open, admitting chill winds and brilliant sunlight." END IF. VERB open DOES "A gust of cold wind hits you in the face." END VERB. VERB examine DOES ONLY DESCRIBE scenic_door. DESCRIBE scenic_slot. END VERB. END OBJECT. OBJECT scenic_slot NAME narrow slot AT waiting_room IS slidable. DESCRIPTION "Next to the door, mounted into the wall, is a narrow slot." VERB examine DOES ONLY "The slot is about ten centimeters wide, but only about two centimeters deep. It is surrounded on its long sides by parallel ridges of metal." END VERB. VERB slide_thru DOES ONLY IF OBJECT = scenic_card THEN "There is a loud buzz and then a click from the locking mechanism. The door opens and cold air blows into the room." MAKE scenic_door NOT locked. MAKE scenic_door NOT closed. IF Floyd HERE AND Floyd IS NOT declaimed THEN "$n$n¨I've got a card just like that!¨ says Floyd. He looks through several of his compartments, then glances at you suspiciously." MAKE Floyd declaimed. END IF. ELSE "A pleasant voice chimes from a hidden speaker: ¨Access denied.¨" END IF. END VERB. END OBJECT. OBJECT widget1 NAME light widget AT waiting_room IS takable. HAS weight 5. VERB examine DOES ONLY "This is basically just a widget. There are a couple of round flanges at one end and a sort of a hole for a screw at the other end. It's not very big or heavy." END VERB. END OBJECT. OBJECT widget2 NAME heavy widget AT waiting_room IS takable. HAS weight 20. VERB examine DOES ONLY "This widget is about the size of a toaster and very heavy." END VERB. END OBJECT. LOCATION scenic_overlook NAME Scenic Overlook DESCRIPTION "You're at a small balcony overlooking a magnificent view indeed! Apparently this area is located at the top of a gigantic cliff in the middle of a range of high mountains extending to the horizon. Looking down on the mountains you feel as if you're at the top of the world. A chill wind is blowing and the sky is absolutely clear and a very deep blue. An ordinary-looking doorway leads back into the cliff.$n" EXIT w TO waiting_room. END LOCATION. -- That stuff just sets up a few rooms and objects to mess around in and -- with. This next bit sets up Floyd the robot. In fact there are THREE -- Floyd-objects: one for when he is awake, one when he is turned off, -- and an actor that follows him everywhere and fakes his actions. -- First, his home and posessions. LOCATION robot_shop NAME Robot Shop DESCRIPTION "This room, with an exit north, is filled with robot-like devices of every conceivable description, all in various states of disassembly.$n" EXIT n TO waiting_room. END LOCATION. OBJECT scenic_card NAME Scenic Overlook Access Card AT limbo IS takable. IS a_card. HAS weight 1. END OBJECT. -- Floyd the robot, when alive and active. -- His attributes: -- woken -- Has he been activated for the first time yet? -- working -- Is he on? -- searched -- Have you searched him and taken the access card? -- declaimed -- Has he given his speech about the access card? -- carrying -- Have you given him an object to carry? Careful -- experimentation with the real _Planetfall_ showed that -- Floyd never carries more than one object at once. -- I didn't simply use LIMITS because Floyd responds -- differently when he keeps or drops objects. OBJECT Floyd NAME multiple purpose robot AT limbo CONTAINER HEADER "The multiple purpose robot is holding:" IS takable. -- IS openable. -- These two are just to get past the global CHECKs IS an_actor. IS NOT woken. IS NOT working. IS NOT searched. IS NOT carrying. IS NOT declaimed. DESCRIPTION "There is a multiple purpose robot here.$n" IF Floyd IS carrying THEN LIST Floyd. END IF. VERB examine DOES ONLY "From its design, the robot seems to be of the multi-purpose sort. It is slightly cross-eyed, and its mechanical mouth forms a lopsided grin." END VERB. VERB take DOES ONLY "You manage to lift Floyd a few inches off the ground, but he is too heavy and you drop him suddenly. Floyd gives a surprised squeal and moves a respectable distance away." END VERB. VERB open DOES ONLY "Floyd giggles and pushes you away. ¨You're tickling Floyd!¨ He clutches at his side panels, laughing hysterically. Oil drops stream from his eyes." END VERB. VERB turn_on DOES ONLY "He's already been activated." END VERB. VERB turn_off DOES ONLY MAKE Floyd NOT working. "Floyd, shocked by this betrayal from his new-found friend, whimpers and keels" IF Floyd IS carrying THEN "over, dropping what he was carrying." MAKE Floyd NOT carrying. EMPTY Floyd HERE. ELSE "over." END IF. LOCATE off_floyd HERE. LOCATE Floyd AT limbo. LOCATE real_floyd AT limbo. USE SCRIPT 3 FOR real_floyd. END VERB. VERB give DOES IF Floyd IS carrying THEN "Floyd examines the $o, shrugs, and drops it." LOCATE obj HERE. ELSE "¨Neat!¨ exclaims Floyd. He thanks you profusely." LOCATE obj IN Floyd. MAKE Floyd carrying. END IF. END VERB. VERB play_with DOES ONLY "You play with Floyd for several centichrons until you drop to the floor, exhausted. Floyd pokes at you gleefully. ¨C'mon! Let's play some more!¨" END VERB. VERB talk_to DOES ONLY "¨Hi!¨ Floyd grins and bounces up and down." END VERB. END OBJECT. -- off_floyd: This is Floyd when he is not switched on. OBJECT off_floyd NAME multiple purpose robot AT robot_shop IS openable. -- again, this is just to get past global checks DESCRIPTION IF Floyd IS NOT woken THEN "$nOnly one robot, about four feet high, looks even remotely close to being in working order.$n" ELSE "There is a multiple purpose robot here.$n" END IF. VERB examine DOES ONLY "The de-activated robot is leaning against the wall, its head lolling to the side. It is short, and seems to be equipped for general-purpose work. It has apparently been turned off." END VERB. VERB turn_on DOES ONLY IF Floyd IS woken THEN "Floyd jumps to his feet, hopping mad. ¨Why you turn Floyd off?¨ he asks accusingly." MAKE Floyd working. LOCATE Floyd HERE. LOCATE real_floyd HERE. LOCATE off_floyd AT limbo. USE SCRIPT 2 FOR real_floyd. ELSE "Nothing happens." USE SCRIPT 1 FOR real_floyd. END IF. END VERB. VERB turn_off DOES ONLY "The robot doesn't seem to be on." END VERB. VERB open DOES ONLY IF Floyd IS searched THEN "Your search discovers nothing in the robot's compartments except a single crayon which you leave where you found it." ELSE "In one of the robot's compartments you find and take a magnetic-striped card embossed ¨Seenik Overluuk Akses Kard.¨" MAKE Floyd searched. LOCATE scenic_card HERE. LOCATE scenic_card IN inventory. END IF. END VERB. END OBJECT. -- The actor Floyd, which carries out all actions you do not instigate. -- real_floyd has these attributes: -- random_action: a holder for random numbers for his next silly act. -- been_alone: how long you and Floyd have been apart, which governs -- whether the player sees "Floyd follows you" or the other -- message. -- And these scripts: -- script 1: For when Floyd is first activated. -- script 2: His normal wandering about. -- script 3: Used to quietly abort whatever he's doing (ie, he's turned off.) ACTOR real_floyd AT limbo HAS random_action 0. HAS been_alone 0. DESCRIPTION SCRIPT 1. STEP " " STEP MAKE Floyd woken. MAKE Floyd working. LOCATE Floyd AT hero. LOCATE real_floyd AT hero. LOCATE off_floyd AT limbo. "$pSuddenly, the robot comes to life and its head starts swivelling about. It notices you and bounds over. ¨Hi! I'm B-19-7, but to everyperson I'm called Floyd. Are you a doctor-person or a planner-person? Isn't it nice that Mark Sachs wrote this example? Let's play Hider-and-Seeker you with me.¨" USE SCRIPT 2. SCRIPT 2. STEP IF hero NOT HERE THEN INCREASE been_alone OF real_floyd BY 1. ELSE SET been_alone OF real_floyd TO 0. END IF. IF RANDOM 1 TO 3 = 1 THEN SET random_action OF real_floyd TO RANDOM 1 TO 21. IF random_action OF real_floyd = 1 THEN "$pFloyd wanders restlessly around the room." END IF. IF random_action OF real_floyd = 2 THEN "$pFloyd paces impatiently." END IF. IF random_action OF real_floyd = 3 THEN "$pFloyd lowers his voice and tells you the latest rumors about Dr. Fizpick." END IF. IF random_action OF real_floyd = 4 THEN "$pFloyd absent-mindedly oils one of his joints." END IF. IF random_action OF real_floyd = 5 THEN "$pFloyd tells you about the time he helped someone sharpen a pencil." END IF. IF random_action OF real_floyd = 6 THEN "$pFloyd yawns and looks bored." END IF. IF random_action OF real_floyd = 7 THEN "$pFloyd reminisces about his friend Lazarus, a medical robot." END IF. IF random_action OF real_floyd = 8 THEN "$pFloyd examines himself for signs of rust." END IF. IF random_action OF real_floyd = 9 THEN "$pFloyd cranes his neck to see what you are doing." END IF. IF random_action OF real_floyd = 10 THEN "$pFloyd recalls the time he bruised his knee." END IF. IF random_action OF real_floyd = 11 THEN "$pFloyd whistles tunelessly." END IF. IF random_action OF real_floyd = 12 THEN "$pFloyd produces a crayon from one of his compartments and scrawls his name on the wall." END IF. IF random_action OF real_floyd = 13 THEN "$pFloyd says ¨Floyd going exploring. See you later.¨ He glides out of the room." LOCATE Floyd AT limbo. LOCATE real_floyd AT limbo. SET been_alone OF real_floyd TO 2. END IF. IF random_action OF real_floyd = 14 THEN "$pFloyd relates some fond memories about his old friend Lazarus." END IF. IF random_action OF real_floyd = 15 THEN "$pFloyd absent-mindedly recites the first six hundred digits of pi." END IF. IF random_action OF real_floyd = 16 THEN "$pFloyd asks if you want to play Hucka-Bucka-Beanstalk." END IF. IF random_action OF real_floyd = 17 THEN "$pFloyd chants the death scene from ¨Carmen¨." END IF. IF random_action OF real_floyd = 18 THEN "$pFloyd rubs his head affectionately against your shoulder." END IF. IF random_action OF real_floyd = 19 THEN "$pFloyd frets about the possibility of his batteries failing." END IF. IF random_action OF real_floyd = 20 THEN "$pFloyd notices a mouse scurrying by and tries to hide behind you." END IF. IF random_action OF real_floyd = 21 THEN "$pFloyd sings an ancient ballad, totally out of key." END IF. ELSE IF hero NOT HERE THEN LOCATE Floyd AT hero. LOCATE real_floyd AT hero. IF been_alone OF real_floyd = 1 THEN "$pFloyd follows you." IF Floyd AT scenic_overlook THEN "¨Ooo. Nice view,¨ Floyd says appreciatively." END IF. ELSE IF RANDOM 1 TO 2 = 1 THEN "$pFloyd bounds into the room. ¨Floyd here now!¨ he cries." ELSE "$pFloyd rushes into the room and barrels into you. ¨Oops, sorry,¨ he says. ¨Floyd not looking at where he was going to.¨" END IF. END IF. SET been_alone OF real_floyd TO 0. END IF. END IF. USE SCRIPT 2. SCRIPT 3. STEP " " END ACTOR. -- START section... very simple in this case. START AT waiting_room. "You awaken foggily to find yourself in an unfamiliar white room..."