-- ALAN etude featuring Floyd from Planetfall. -- Mostly, this demonstrates how to construct fairly elaborate actors; -- it also uses some other basic ALAN techniques. -- -- Originally written by Mark Sachs over a long span of time concluding -- on October 13, 1993. Mark can now be reached at -- markbriansachs@gmail.com -- http://www.project-apollo.net -- -- Converted to ALAN v3 by Anssi Räisänen on 23 September 2010. -- -- 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. ADD TO EVERY THING IS closed. NOT locked. NOT openable. NOT takable. NOT slidable. NOT a_card. NOT an_actor. weight 0. END ADD TO. SYNONYMS east = e. west = w. z = 'wait'. i = 'inventory'. x = 'examine'. l = 'look'. get = take. run = slide. thru = through. floyd = robot. SYNTAX 'look' = 'look'. 'quit' = 'quit'. 'wait' = 'wait'. 'score' = 'score'. take_inv = 'inventory'. take = take (obj) * WHERE obj ISA THING ELSE "You can't take that." drop = drop (obj) * WHERE obj ISA THING ELSE "You can't drop that." read = read (obj) * WHERE obj ISA THING ELSE "You can't read that." examine = examine (obj) * WHERE obj ISA THING ELSE "You can't examine that." open = open (obj) * WHERE obj ISA THING ELSE "You can't open that." close = close (obj) * WHERE obj ISA THING ELSE "You can't close that." turn_on = turn 'on' (obj) WHERE obj ISA THING ELSE "You can't turn that on." turn_on = turn (obj) 'on'. turn_off = turn off (obj) WHERE obj ISA THING ELSE "You can't turn that off." turn_off = turn (obj) off. play_with = 'play' 'with' (obj) WHERE obj ISA THING ELSE "You can't play with that." talk_to = talk 'to' (obj) WHERE obj ISA THING ELSE "You can't talk to that." give = 'give' (obj) 'to' (recip) WHERE obj ISA OBJECT ELSE "You can't give that." AND recip ISA ACTOR ELSE "That can't receive things." slide_thru = 'slide' (obj) 'through' (ind) WHERE obj ISA OBJECT ELSE "You can't slide that." AND ind ISA OBJECT ELSE "You can't slide anything through that." 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 hero. END VERB. ADD TO EVERY OBJECT VERB open CHECK obj IS openable ELSE "That would be a neat trick, opening the" SAY THE obj. "$$..." AND obj IS closed ELSE "The" SAY obj. "is already open." AND obj IS NOT locked ELSE "It isn't opening." DOES MAKE obj NOT closed. "The" SAY obj. "opens." END VERB. END ADD TO. ADD TO EVERY OBJECT VERB close CHECK obj IS openable ELSE "You can't even open the" SAY obj. "$$, much less close it." AND obj IS NOT closed ELSE "It _is_ closed!" DOES MAKE obj closed. "You close the" SAY obj. "." END VERB. END ADD TO. ADD TO EVERY OBJECT VERB take CHECK obj IS takable ELSE "You can't take that." AND obj NOT IN hero ELSE "You did already, remember?" DOES IF obj IN Floyd THEN MAKE Floyd NOT carrying. END IF. LOCATE obj IN hero. "Taken." END VERB. END ADD TO. ADD TO EVERY OBJECT VERB drop CHECK obj IN hero ELSE "But you're not carrying that!" DOES LOCATE obj HERE. "Dropped." END VERB. END ADD TO. ADD TO EVERY OBJECT VERB read DOES "That isn't something you can read." END VERB. END ADD TO. ADD TO EVERY OBJECT VERB examine DOES "You see nothing special." END VERB. END ADD TO. ADD TO EVERY OBJECT VERB give CHECK obj IN hero ELSE "You don't have that." AND recip IS an_actor ELSE "You can't give a" SAY obj. "to a" SAY recip. "$$!" END VERB. END ADD TO. ADD TO EVERY OBJECT VERB play_with DOES "You fiddle with the" SAY obj. "for a while. Gosh, that was fun." END VERB. END ADD TO. ADD TO EVERY THING VERB talk_to DOES "Talking to a" SAY obj. "is usually taken as a sign of impending mental collapse." END VERB. END ADD TO. ADD TO EVERY OBJECT VERB turn_on DOES "You can't turn that on." END VERB. END ADD TO. ADD TO EVERY OBJECT VERB turn_off DOES "You can't turn that off." END VERB. END ADD TO. ADD TO EVERY OBJECT VERB slide_thru WHEN obj CHECK obj IN hero 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. END ADD TO. -- 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. THE hero ISA ACTOR CONTAINER TAKING THING. 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 THE hero. -- Where stuff goes when we want to hide it from the player. THE limbo ISA LOCATION END THE. -- Starting room, and a few bits and pieces to play with. THE waiting_room ISA LOCATION 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 THE. THE scenic_door ISA OBJECT 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 THE. THE scenic_slot ISA OBJECT 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 WHEN ind DOES ONLY IF obj = 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 THE. THE widget1 ISA OBJECT 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 THE. THE widget2 ISA OBJECT 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 THE. THE scenic_overlook ISA LOCATION 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 THE. -- 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. THE robot_shop ISA LOCATION 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 THE. THE scenic_card ISA OBJECT NAME Scenic Overlook Access Card AT limbo IS takable. IS a_card. HAS weight 1. END THE. -- 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. -- 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.) THE Floyd ISA ACTOR 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. HAS random_action 0. HAS been_alone 0. 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 floyd AT limbo. USE SCRIPT s3 FOR floyd. END VERB. VERB give DOES IF Floyd IS carrying THEN "Floyd examines the" SAY obj. "$$, 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. SCRIPT s1. STEP " " STEP MAKE Floyd woken. MAKE Floyd working. LOCATE Floyd AT hero. LOCATE 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 s2. SCRIPT s2. STEP IF hero NOT HERE THEN INCREASE been_alone OF floyd BY 1. ELSE SET been_alone OF floyd TO 0. END IF. IF RANDOM 1 TO 3 = 1 THEN SET random_action OF floyd TO RANDOM 1 TO 21. IF random_action OF floyd = 1 THEN "$pFloyd wanders restlessly around the room." END IF. IF random_action OF floyd = 2 THEN "$pFloyd paces impatiently." END IF. IF random_action OF floyd = 3 THEN "$pFloyd lowers his voice and tells you the latest rumors about Dr. Fizpick." END IF. IF random_action OF floyd = 4 THEN "$pFloyd absent-mindedly oils one of his joints." END IF. IF random_action OF floyd = 5 THEN "$pFloyd tells you about the time he helped someone sharpen a pencil." END IF. IF random_action OF floyd = 6 THEN "$pFloyd yawns and looks bored." END IF. IF random_action OF floyd = 7 THEN "$pFloyd reminisces about his friend Lazarus, a medical robot." END IF. IF random_action OF floyd = 8 THEN "$pFloyd examines himself for signs of rust." END IF. IF random_action OF floyd = 9 THEN "$pFloyd cranes his neck to see what you are doing." END IF. IF random_action OF floyd = 10 THEN "$pFloyd recalls the time he bruised his knee." END IF. IF random_action OF floyd = 11 THEN "$pFloyd whistles tunelessly." END IF. IF random_action OF 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 floyd = 13 THEN "$pFloyd says ""Floyd going exploring. See you later."" He glides out of the room." LOCATE Floyd AT limbo. LOCATE floyd AT limbo. SET been_alone OF floyd TO 2. END IF. IF random_action OF floyd = 14 THEN "$pFloyd relates some fond memories about his old friend Lazarus." END IF. IF random_action OF floyd = 15 THEN "$pFloyd absent-mindedly recites the first six hundred digits of pi." END IF. IF random_action OF floyd = 16 THEN "$pFloyd asks if you want to play Hucka-Bucka-Beanstalk." END IF. IF random_action OF floyd = 17 THEN "$pFloyd chants the death scene from ""Carmen""." END IF. IF random_action OF floyd = 18 THEN "$pFloyd rubs his head affectionately against your shoulder." END IF. IF random_action OF floyd = 19 THEN "$pFloyd frets about the possibility of his batteries failing." END IF. IF random_action OF floyd = 20 THEN "$pFloyd notices a mouse scurrying by and tries to hide behind you." END IF. IF random_action OF 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 floyd AT hero. IF been_alone OF 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 floyd TO 0. END IF. END IF. USE SCRIPT s2. SCRIPT s3. STEP " " END THE. -- off_floyd: This is Floyd when he is not switched on. THE off_floyd ISA OBJECT 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 floyd HERE. LOCATE off_floyd AT limbo. USE SCRIPT s2 FOR floyd. ELSE "Nothing happens." USE SCRIPT s1 FOR 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" Style Emphasized. "Seenik Overluuk Akses Kard" Style Normal. "." MAKE Floyd searched. LOCATE scenic_card HERE. -- Incase hands are full we want it make sure that it ends up here. LOCATE scenic_card IN hero. END IF. END VERB. END THE. -- START section... very simple in this case. START AT waiting_room. "You awaken foggily to find yourself in an unfamiliar white room..."