Inform Beginner's Guide
Total Page:16
File Type:pdf, Size:1020Kb
The Inform Beginner’s Guide Roger Firth and Sonja Kesserich First Edition: April 2002 With a Foreword by Graham Nelson The Inform Beginner’s Guide Authors: Roger Firth and Sonja Kesserich Editor: Dennis G. Jerz Printed edition managed by: David Cornelson Cover: First Steps (watercolour and crayon on paper, 2002) Harry Firth (2000—) This book and its associated example games are copyright © Roger Firth and Sonja Kesserich 2002. Their electronic forms may be freely distributed provided that: (a) distributed copies are not substantially different from those archived by the authors, (b) this and other copyright messages are always retained in full, and (c) no profit is involved. Exceptions to these conditions must be negotiated directly with the authors. The authors assume no liability for errors and omissions in this book, or for damages or loss of revenue resulting from the use of the information contained herein, or the use of any of the software described herein. Inform, the program and its source code, its example games and documentation, are copyright © Graham Nelson 1993—2002. First Edition: April 2002 Soon to be published by The Interactive Fiction Library (IFLibrary.com) PO Box 3304, St Charles, Illinois 60174 Printed in the United States of America ISBN 0-9713119-2-7 CONTENTS Contents Foreword by Graham Nelson . 7 About this guide . 9 Scope and approach 10 Presentation and style 10 Useful Internet resources 11 Acknowledgements 12 1 • Just what is interactive fiction? . 13 2 • Tools of the trade . 17 Inform on an IBM PC 19 Inform on an Apple Macintosh 23 More about the editor 24 More about the compiler 24 More about the interpreter 25 3 • Our first Inform game . 27 Creating a basic source file 27 Understanding the source file 29 Defining the game’s locations 30 Joining up the rooms 32 Adding the bird and the nest 35 Adding the tree and the branch 38 Finishing touches 39 4 • Reviewing the basics . 41 Constants and variables 41 Object definitions 42 Object relationships – the object tree 44 Things in quotes 47 Routines and statements 48 5 • Heidi revisited . 51 Listening to the bird 51 Entering the cottage 53 Climbing the tree 55 Dropping objects from the tree 56 Is the bird in the nest? 58 Summing up 58 6 • William Tell: a tale is born . 61 Initial setup 61 Object classes 64 3 CONTENTS 7 • William Tell: the early years . 69 Defining the street 69 Adding some props 71 The player’s possessions 73 Moving further along the street 75 Introducing Helga 76 8 • William Tell: in his prime . 81 The south side of the square 81 The middle of the square 82 The north side of the square 89 9 • William Tell: the end is nigh . 91 The marketplace 91 Gessler the governor 95 Walter and the apple 95 Verbs, verbs, verbs 97 10 • Hero’s Fate: take 1 . 105 Fade up on: a nondescript city street 105 A hero is not an ordinary person 112 11 • Hero’s Fate: take 2 . 115 A homely atmosphere 115 A door to adore 119 12 • Hero’s Fate: take 3 . 127 Too many toilets 127 Don’t shoot! I’m only the barman 130 13 • Hero’s Fate: the final cut . 137 Additional catering garnish 137 Toilet or dressing room? 138 And there was light 141 Amazing technicolour dreamcoats 146 It’s a wrap 147 14 • Some last lousy points . 151 Expressions 151 Internal IDs 152 Statements 152 Directives 154 Objects 155 Routines 157 Reading other people’s code 159 15 • Compiling your game . 167 Ingredients 167 Compiling à la carte 170 Switches 171 4 CONTENTS 16 • Debugging your game . 173 Command lists 174 Spill them guts 174 What on earth is going on? 175 Super-powers 177 Infix: the harlot’s prerogative 178 No matter what 179 17 • *** You have won *** . 181 Appendix A • How to play an IF game . 185 Appendix B • “Heidi” story . 189 Transcript of play 189 Game source code – original version 190 Game source code – revisited 192 Appendix C • “William Tell” story . 195 Transcript of play 195 Game source code 198 Appendix D • “Captain Fate” story . 209 Transcript of play 209 Game source code 212 Appendix E • Inform language . 225 Literals 225 Names 225 Constants 225 Variables and arrays 225 Expressions and operators 226 Classes and objects 226 Manipulating the object tree 227 Message passing 227 Uncommon and deprecated statements 227 Statements 227 Routines 227 Flow control 228 Loop control 228 Displaying information 228 Verbs and actions 229 Other useful directives 229 Uncommon and deprecated directives 229 5 CONTENTS Appendix F • Inform library . 231 Library objects 231 Library constants 231 User-defined constants 231 Library variables 232 Library routines 232 Object properties 234 Object attributes 237 Optional entry points 238 Group 1 actions 238 Group 2 actions 239 Group 3 actions 239 Fake actions 240 Appendix G • Glossary . 241 Index . 247 6 FOREWORD BY GRAHAM NELSON Foreword by Graham Nelson t would, I think, be immodest to compare myself to Charles Bourbaki (1816–97), French hero of the Crimean War and renowned strategist, a man offered nothing less as a reward than the throne of Greece (he declined). It may be in order, though, to say a few words about his fictitious relative Nicholas, the most dogged, lugubrious, interminably thorough and clotted writer of textbooks ever to state a theorem. Rather the way Hollywood credits movies for which nobody wants the blame to the director “Alan Smithee” (who by now has quite a solid filmography and even gets the occasional cinema festival), so in mathematics many small results are claimed to be the work of Nicholas Bourbaki. Various stories are told of the birth of Bourbaki, under whose name young Parisian mathematicians have clubbed together since 1935 to write surveys of whole fields of algebra. His initials, it may be noted, are NB. Some say “Bourbaki” was an in-joke at the Ecole Normale Supérieure (much as “zork” and “foobar” were at MIT), going right back to a practical joke in 1880 when a pupil successfully impersonated a visiting “General Claude Bourbaki”. Folklore also has it that the real general was notorious when on manoeuvres for being able to eat anything if need be – stale biscuit, raw turnips, his horse, his horse’s hay, his horse’s leather nosebag that the hay used to be in – just as Nicholas Bourbaki would have to eat everything there was to eat in the theory of algebra, no matter how tooth-grinding or chewy. To give credit where it’s due, Bourbaki’s forty volumes are quite useful. Or, actually, they aren’t, but it’s nice to know they’re there. It was on reading this present book that I realised the melancholy truth: that my own volume on Inform, the Designer’s Manual, is a Bourbaki. It has to cover every last thing, from Icelandic accents to assembly language to fake actions, not to mention fake fake actions, to grouping together almost-but-not-quite-identical objects such as Scrabble tiles – matters which a dedicated Inform designer might need to look up once in a lifetime, or then again might not. To be sure, the basics do turn up every so often, especially in Chapters II and III, but despite my best intention it is a gentle introduction only if you pick your way through as if on stepping stones. This book, on the other hand, is a follow-as-you-go tutorial, covering the basics thoroughly and a little at a time. Where the Designer’s Manual tries never to retrace its steps, so for instance there is just one section on locations, the Beginner’s Guide works its way through three whole games, giving it three chances to visit every subject, reinforcing and showing a little more each time. I should like to say that my first reaction, when out of the blue the authors sent me advance proofs, was to exclaim with delight at the lucid, uncluttered, sensible approach. Truthfully, however, that was my third reaction, the first being jealousy (it’s all right for you, you don’t have to document how the parser calculates GNA sets for noun clauses) and the second pique (you’ve cast the gizbru spell: turn dangerous object into a harmless one at my book). When it comes 7 FOREWORD BY GRAHAM NELSON down to it, though, there is no greater compliment any writer can be paid than to have someone else choose to write a book about his work, so I thank Roger and Sonja for their gesture, as well as the fine job they have done. That is quite enough talking about myself, as Inform belongs to all its users, to the hundreds of serious writers of interactive fiction who find it helpful, and for almost a decade it has been a collective enterprise. Today nobody remembers who suggested what. Its world-modelling rules now resemble a New England patchwork quilt, to which each house in the village contributes one woven square. As you read this book, you might want to bear in mind that such a quilt is never finished, and always has room for one more square from a newly arrived neighbour. St Anne’s College University of Oxford April 2002 8 ABOUT THIS GUIDE About this guide ext adventures, otherwise known collectively as interactive fiction (IF), were highly popular computer games during the 1980s. With the evolution of computer technology they faded from the market, unable to compete with increasingly sophisticated graphical games; however, interactive fiction was far from dead. The growth of the Internet and the Usenet discussion forums brought together enthusiasts with a lot to say.