Notepad by Jim Aikin Search for other extensions by this author Approved for the Public Library


Download version 3/150510For Inform 7 6L38



A system for creating an in-game notepad that the player can write on.

Tags world-model


Section: What it does. Notepad allows the author to create one or more things called notepads. The player can write text on a notepad, read the text, erase the text, add to the text, erase specific strings of characters from the text, and copy the text from one notepad to another. Text on a notepad can be write-protected. Other characters can also use notepads, if ordered to do so by the player. By default, a writing implement is needed to write on a notepad (but not to erase what's on it -- if you want to implement an eraser object, you'lll need to customize the extension). The writer must be carrying the writing implement. Version 3 is updated to work with Inform 6L38. The Check rules in Sections 4 and 5 have been edited to reflect Inform's more strict handling of the declaration of temporary variables, the now deprecated syntax "change X to Y" has been removed, and references to indexed text have been dropped. Adaptive text has been implemented so as to allow the use of third-person and past tense narrative. Section: Using Notepad. To use Notepad, first create a writing implement and a notepad. The writing implement is not a special kind of thing; anything can be a writing implement (for instance, a fountain pen, which might be implemented as a container that needs to be loaded with ink). Add the writing implement to the list of allowed-pens of the notepad: The player carries a piece of chalk. The player carries a slate. The slate is a notepad. The allowed-pens of the slate is {chalk}. Any number of writing implements can be included in the allowed-pens list for a notepad. If you'd rather let the player write on the notepad without bothering with a writing implement (perhaps because the notepad object is a hand-held computer with a QWERTY keyboard), forget about the allowed-pens list. Instead, set the pen-needed property of the notepad to false: The foggy mirror is a notepad. The pen-needed of the foggy mirror is false. The text of a notepad is held in a property called memo. If you want the notepad to start the game with a message already written on it, put something in the memo property: The memo of the foggy mirror is "Beware! Ghouls!" By default, when a notepad is examined, its memo is printed out in a separate paragraph after the description. If you don't want this effect, perhaps because you're handling it yourself in the description, you can override the default like this: The notepad output rule is not listed in any rulebook. In practice, long texts may slow the interpreter noticeably. The erasing it from action can become quite sluggish with long texts. Section: New Commands The player (or an NPC who has been ordered to do so -- all of these actions can also be carried out by an NPC) can "read <notepad>". The player can "write <any text> on <notepad>". "scribble" and "jot" are understood as synonyms for "write", and either "in" or "on" can be used. The extension makes no distinction between notepads that one would expect to write on (such as a blackboard) and those that one would expect to write in (such as a notebook). All input arrives in the memo buffer in lower-case letters. The player can "add <any text> to <notepad>". This appends the new text at the end of the existing text. ("append" is understood as a synonym.) If the notepad is blank, "add" works exactly like "write". The player can "erase <notepad>". This deletes the entire contents of the notepad. The player can "erase <any text> from <notepad>". ("delete" works as a synonym for "erase"). This command searches the entire text and removes all instances of <any text> from it. The erasing it from command is case-insensitive, so it will delete capital letters (if any have been included in a memo text by the author). The player can "copy <notepad> to <another notepad>". Copying overwrites the current contents of the destination notepad. A notepad can be write-protected using the command "protect <notepad>". When it is write-protected, the write, add to, erase, erase from, and copy to commands are disallowed. The commands can be re-enabled using "unprotect <notepad>". This feature is to allow the player to take notes on game-play and avoid accidentally overwriting or erasing the notes. Section: Known Issues The notepad doesn't handle space characters perfectly. It will delete extra spaces when the erasing it from action would create them, but spaces themselves can't be erased (except by erasing the words on both sides of a space, and including the space character in the command). Due to the sheer number of outputs needed and their close linkages to text, no attempt has been made to extract the output text into a table for ease of customization or use in other languages. To change the output, you'll need to copy the action rules into your source, give your copies new names, and then use a command such as "the new check erasing rule is listed instead of the ordinary check erasing rule in the check erasing rulebook." All text is converted to lower-case when being entered. (Actually, by the parser before the write command is executed.) For this reason, it's not possible to capitalize words that are written. However, text created by the game's author can contain capitals, and these will be preserved when the text is copied from one notepad to another. It's not necessary that the user be holding the notepad in order to use it. This is meant to accommodate notepad objects such as a whiteboard, which can't be held. Bugs should be reported to the author at or Section: About the Examples Memorabilia is a kind of catch-all example, with which we can try writing, adding, erasing, copying, dropping needed pen objects, and so on. Beethoven uses the notepad object in an unconventional way (with a little coding help from Jesse McGrew). The NPC is deaf, and won't respond to normal commands. But he will respond to commands written in the conversation book if the book is then shown to him. Only one command, "play the piano", is implemented, but this device could form the basis of an entire, though admittedly cumbersome, conversation system. It works by storing the memo of the conversation book in the queued command and then retrieving it using the Rule for reading a command. The truth state Beethoven-willing will only be true immediately after the book has been shown to him. Example: * Memorabilia - Some objects the player can write in. *: "Memorabilia" Include Notepad by Jim Aikin. The Lab is a room. The player carries a fish. The description of the fish is "The fish [are] remarkably scaly." The player carries a pencil and a piece of chalk. The player carries a slate. The slate is a notepad. The description of the slate is "Black." The allowed-pens of the slate is {chalk}. The player carries a notebook. The notebook is a notepad. The description of the notebook is "Dog-eared." The allowed-pens of the notebook is {pencil}. The foggy mirror is in the Lab. The description is "The mirror [are] thickly coated with condensed steam." The foggy mirror is a notepad. The pen-needed of the foggy mirror is false. The memo of the foggy mirror is "Beware! Ghouls!" Test writing with "write message on fish / write message on slate / read slate / drop chalk / add another message to slate / take chalk / add another message to slate". Test reading with "read slate / read fish / read mirror / x mirror". Test erasing with "erase me from slate / read slate / erase slate / read slate". Test copying with "copy mirror to mirror / copy mirror to notebook / drop chalk / copy notebook to slate". Test me with "test writing / test reading / test erasing /test copying". Example: * Beethoven - A deaf NPC who responds only to commands written in the conversation book. *: "Beethoven" Include Notepad by Jim Aikin. Section 1 - The Room & Objects The Messy Front Parlor is a room. "A handsome Broadwood piano dominates this small, cluttered room. Stuff is scattered everywhere. There's even a half-eaten sandwich under the piano." A musical instrument is a kind of thing. The Broadwood piano is scenery in the Messy Front Parlor. The description is "The piano is handsomely inlaid with fleur-de-lis." Understand "handsome", "inlay", and "fleur-de-lis" as the Broadwood piano. The Broadwood piano is a musical instrument. The player carries a conversation book and a quill pen. The conversation book is a notepad. The allowed-pens of the conversation book is {quill pen}. The description of the conversation book is "The deaf composer often used a book of this sort to hold conversations with his friends. They would write whatever they wanted to say to him in the book and then show him the book." Section 2 - Beethoven Beethoven is a man in the Messy Front Parlor. "Beethoven is standing here, scowling at you." The description is "His hair hasn't been combed in days, and his waistcoat is mis-buttoned." Beethoven has some text called the non-response. The non-response of Beethoven is "Beethoven doesn't seem to have heard you." Beethoven-willing is a truth state that varies. Beethoven-willing is false. Instead of asking Beethoven to try playing the piano: if Beethoven-willing is false: say "[non-response of Beethoven][paragraph break]"; otherwise: say "Beethoven says, 'Oh, perhaps.' He sits down at the piano and plays a rapid flurry of notes. Unfortunately, the piano hasn't been tuned in years, and some of the strings seem to be broken. Beethoven seems blissfully unaware of the awful racket." Instead of asking Beethoven to try doing something: if Beethoven-willing is true: say "Beethoven frowns and shakes his head. Perhaps he can't understand what '[memo of the conversation book]' means."; otherwise: say "[non-response of Beethoven][paragraph break]". Persuasion rule for asking Beethoven to try doing something: if Beethoven-willing is true: persuasion succeeds; otherwise: persuasion fails. Section 3 - Letting Beethoven Respond to Written Commands The queued command is a text that varies. Rule for reading a command: if the queued command is empty: now Beethoven-willing is false; make no decision; otherwise: now Beethoven-willing is true; change the text of the player's command to the queued command; now the queued command is "". Instead of showing the conversation book to Beethoven: if the memo of the conversation book is empty, say "Beethoven frowns at the empty page. 'You have an odd sense of humor,' he says gruffly."; otherwise now the queued command is "beethoven, [memo of the conversation book]". Section 4 - The Playing Action Playing is an action applying to one thing. Understand "play [something]" as playing. Check playing: if the noun is not a musical instrument: say "You can't make music on [the noun]!" instead. Carry out playing: say "You try a few tentative notes on [the noun], but it's in such poor condition that you desist almost before you start." Test me with "show book to beethoven / write play the piano in the book / show book to beethoven / beethoven, play the piano / write go north in conversation book / show book to beethoven".