| Author: Joyce Haslam <comus@argonet.co.uk> | |
| Date: 1998/11/27 | |
| Forum: rec.arts.int-fiction | |
| I've been sitting selfishly on this letter from Graham Nelson | |
| for a year: | |
| > I need a class of rooms that are dimly lit so that "take all" does | |
| > not work. I can suppress "you can see" and "exits are", but I don't | |
| > know how to get at the parser. I don't mind the player being able | |
| > to "take all" in brightly lit rooms, and "the dark" is fine, but in | |
| > the class of rooms with the attribute "has dimness" I want | |
| > something like | |
| > "take book" | |
| > "OK" | |
| > "take all" | |
| > "What, even the snakes and spiders?" | |
| Here's a little game which has just the code you need. I've | |
| put a few comments in, but for further explanation, see section | |
| 29 of the Designer's Manual. Note that there are two things to | |
| do -- (1) to make sure that "take all" takes nothing in dim | |
| rooms, and (2) to print a good error message when this rule has | |
| been applied. | |
| You should be able to compile this as is: then try "take all" | |
| in both rooms. ("Drop all", and other uses of "all", should be | |
| unaffected.) | |
| Graham Nelson | |
| --------------- | |
| Constant DEBUG; | |
| Constant Story "Faintly Lit"; | |
| Constant Headline "^An Interactive Answer^"; | |
| Include "Parser"; | |
| Include "VerbLib"; | |
| Class FLRoom | |
| has light; | |
| Object Bright_Room "Bright Room" | |
| with e_to Faintly_Lit_Room, | |
| description | |
| "The Bright Room. A corridor runs east.", | |
| has light; | |
| Object -> green_ball "green ball" | |
| with name "green" "ball"; | |
| Object -> red_disc "red disc" | |
| with name "red" "disc"; | |
| FLRoom Faintly_Lit_Room "Faintly-Lit Room" | |
| with w_to Bright_Room, | |
| description | |
| "The Faintly-Lit Room. A corridor runs west."; | |
| Object -> marble "marble" | |
| with name "marble"; | |
| Object -> feather "feather" | |
| with name "feather"; | |
| Object -> basket "basket" | |
| with name "basket"; | |
| [ Initialise; | |
| location = Bright_Room; | |
| "^^^^^Welcome to the...^"; | |
| ]; | |
| [ ChooseObjects obj code; | |
| if (code == 1) | |
| { ! That is: if the parser wants to include this object in | |
| ! an "all" | |
| if (action_to_be == ##Take or ##Remove | |
| && location ofclass FLRoom) | |
| { ! Force the object to be excluded. The net result is that | |
| ! the parser will be unable to have anything in a "take all" | |
| ! occurring in a faintly-lit room. | |
| return 2; | |
| } | |
| } | |
| return 0; ! Carry on, applying normal parser rules | |
| ]; | |
| [ ParserError error_code; | |
| if (error_code == NOTHING_PE) | |
| { ! The error message printed if an "all" turned out empty | |
| if (action_to_be == ##Take or ##Remove | |
| && location ofclass FLRoom) | |
| "In this faint light, it's not so easy."; | |
| } | |
| return 0; ! Print standard parser error message | |
| ]; | |
| Include "Grammar"; | |
| -- | |
| Graham Nelson | graham@gnelson.demon.co.uk | Oxford, United Kingdom | |
| -- | |
| Joyce Haslam | |
| http://www.argonet.co.uk/users/dljhaslam/ for Gateway to Karos [INFORM] | |
| Powerbase is for RiscOs only | |
Xet Storage Details
- Size:
- 2.91 kB
- Xet hash:
- 429f1b0f0597131ae1262893b2d0ae8a9aff82af0371539cc3ba63b94286dba7
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.