Keyword Interface by Aaron Reed Search for other extensions by this author Approved for the Public Library

Versions

Download version 9/140501For Inform 7 6L38

Links

Description

This extension emulates Blue Lacuna's emphasized keyword system for simplifying common IF input. Nouns, directions, and topics can be typed without a verb to examine, go, or discuss. Works with Glulx or z-code.

Tags input interface

Documentation

This extension emulates the emphasized keyword system for streamlining common IF input, as seen in "Blue Lacuna." Nouns, directions, and topics are highlighted and can be typed without verbs to examine, move, or discuss, respectively. (Topics are implemented only in skeletal form to allow for integration with any conversation system; Keywords for Conversation by Matt Wigdahl, for instance, will integrate it with Eric Eve's Conversation Package extensions.) A full system for letting the player select his own preferred color scheme and keeping games backwards-compatible for players on screen readers or with no color support is also included. The extension is compatible with either z-code or Glulx. A warning: Inform authors using color have poor options on either platform. In z-code games, colors can be freely adjusted, but are limited to a palette of eight neon shades, only a few of which will be readable on any given backdrop. Glulx users can select from a palette of sixteen million colors, but can only make two of these available at a time, and these cannot be changed during play. On z-code, all eight colors are made available to the user and can be adjusted by player or author at any time; on Glulx, the two defaults are blue and green, and only authors can customize this. On both platforms, bold, italics, and fixed-width are offered as alternatives to colored keywords. Section: Basic Usage Keyword Interface allows an emphasis style to be set for one of four possible categories. Each of these can be enabled or disabled independently by the author or player. By default, they are set as follows: Object keyword highlighting is initially true. Direction keyword highlighting is initially true. Topic keyword highlighting is initially false. Parser highlighting is initially false. These can be enabled or disabled at any time during play through a "now" statement, or globally by making a more definitive assertion: Object keyword highlighting is false. If keywords are a crucial component of your game, you can add the following: Keywords required is true. This will bring up a message before your game begins ensuring that players can see the keyword highlighting, and giving them an option to adjust styles. Alternatively, you can advertize the KEYWORD verb to players, which brings up the same menu, or show some stock explanatory text, customized to which keywords are enabled, by using the following phrase, perhaps in the carry out rule for an "about" command: carry out the showing the keyword introduction text activity Section: Objects When object keyword highlighting is set to true, the extension will automatically emphasize non-scenery objects listed by the parser. Objects in descriptive text may be manually emphasized by wrapping them in [o] and [x] substitutions. The Office is a room. "Only a bare [o]bulb[x] illuminates this dim office, empty except for a solitary desk.". A desk and a bare bulb are scenery in the office. On the desk is a telephone book and the lamp. This produces output like the following (where emphasis is marked with asterisks): The Office Only a bare *bulb* illuminates this dim office, empty except for a solitary desk. On the desk are a telephone *book* and a *lamp*. If you want scenery items to be automatically emphasized, you can manually set them as keyworded, or include a line like the following (which would add emphasis to "desk" in the final line above): When play begins: now every scenery thing is keyworded. The emphasized word will be the final word of the object's printed name. To change this, you can use the object's "keyword" text property, which should be one of the other words in the printed name. You can also define an object as "keywordless," in which case it will never be automatically emphasized. A book of memories with keyword "book" is in the Office. Some scattered cigarettes are a keywordless thing in the Office. Produces: "You can also see a *book* of memories and some scattered cigarettes here." Automatic emphasis normally occurs when looking, opening or taking inventory. If you want to disable one of these you can use code like the following: The Keyword Interface highlight objects when looking rule is not listed in any rulebook. Conversely, if you want object highlighting during other times, you can use code like this: Rule for printing the name of a thing (called item) while asking which do you mean: carry out the object keywording activity with item. Section: Directions When direction keyword highlighting is set to true and cardinal directions are wrapped in brackets in room descriptions, these will be emphasized as they are printed. "Gloomy passages depart to the [south] and [east]." Compassless navigation as seen in Blue Lacuna can be implemented by adding a directional keyword as a synonym for the intended direction, limiting this to the specific room in which that keyword is valid, and wrapping the relevant word in "d" and "x" tags in the descriptive text. "Gloomy passages depart down a dusty set of [d]stairs[x] and through a wide [d]passage[x]." Understand "stairs" as south when location is Gloomy Tunnel. Understand "passage" as east when location is Gloomy Tunnel. An "exits" verb is included with Keyword Interface to assist blind users or those without color interpreters (who in the above example would have no way of knowing which words correspond to movement). EXITS lists all of the cardinal exits from the current location. If your game uses compassless navigation, you may want to extend this verb to print your keywords instead (see the "Gnome's Holiday" example below for one way to do this). Section: Topics Since there are so many different conversation systems, support for highlighting conversation topics is only vestigial. It's turned on when "topic keyword highlighting" is set to true and you can invoke it with the "[t]topic[x]" wrapper, but everything else will have to be done by hand to match your own conversation system. Again, see "Gnome's Holiday" for a simple example of a keyword-based conversation system. Section: Parser Messages The extension can also style parser messages differently from normal game text. This may be useful to authors who wish to differentiate error messages ("I didn't understand the first part of that.") from in-game admonishments ("You wouldn't be caught dead wearing that.") Parser error highlighting is disabled by default; you can turn it on with Parser highlighting is true. If your game defines new parser error messages or rewrites existing ones, you should wrap them in the "as the parser" and "as normal" say statements: Understand "floop" as a mistake ("[as the parser]To cast a spell, you must cast it on something, like FLOOP THE MATTRESS.[as normal]"). Section: Control To change the default color values at the start of play, authors can use syntax like: The style of object-word is keyword-cyan. The four modes are object-word, direction-word, topic-word, and parser-word. For Glulx games, possible styles are keyword-color1-style and keyword-color2-style; for z-code games, they are keyword-red, keyword-green, keyword-yellow, keyword-blue, keyword-magenta, keyword-cyan, keyword-white, and keyword-black. Both VMs provide the additional styles keyword-bold-style, keyword-italics-style, keyword-fixedwidth-style, and keyword-no-style. To change the Glulx colors, you can adjust g-color1 and g-color2 by amending the Table of Common Color Values-- see the documentation for "Glulx Text Effects" by Emily Short for more information. Table of Common Color Values (amended) glulx color value assigned number g-color1 15645627 All messages the extension prints are customizable responses. Use the RESPONSES testing command to view them, then adjust with a line like the following: The setup keyword emphasis rule response (B) is "This is what [o]objects[x] look like." Section: Screen Reader Mode By typing "screen reader" or selecting the appropriate option from the keyword customization menu, players can set the internal variable "screen reader mode" to true. Blind players and those without color interpreters can activate this mode. This might be useful to provide an alternative if your game contains other visual components such as a map, or uses color in puzzles. The extension provides two verbs to assist color-challenged players: a "things" command which prints a list of nearby objects, and an "exits" command which summarizes the nearby directions. If you're using compassless navigation, you may want to customize the exits command to make use of your custom direction names. Additionally, if your game features conversation, strongly consider building a "topics" command to round out the set. Section: Disambiguation Inform's normal disambiguation assumes that every command begins with a verb, which means conflicts between keywords, and between keywords and verbs, are hard or impossible to control. The best solution is to make sure your object, direction, and topic keywords have no overlap. *If an object and direction keyword* are in the same scope, the parser silently assumes the player means the direction keyword, and will print a seemingly useless "(the object)" clarification if the player manually examines that object instead. *If a highlighted keyword matches a verb*, the verb will take precedence. For example, typing "set" to reference a chess set would instead produce the message "What do you want to set?" The best way to avoid this is to change the keyword and description of the object to avoid mentioning the verb word-- in this case "chessboard" might be a good substitute. You could also disable the verb if it's not one your story uses (see "Overriding existing commands" in the docs). *Conversation systems should take precedence over objects* since this is what players will expect. See the example below for one implementation of this. Example: * Sense of Direction - A simple usage of the extension to print bold compass directions. The flexibility of Keyword Interface means it can be used for multiple purposes. Here we strip away and focus some of its functionality to simply print compass directions in bold. *: "Sense of Direction" Include Keyword Interface by Aaron Reed. Object keyword highlighting is false. The style of direction-word is keyword-bold-style. Labyrinth is south of Passage and west of Halls. Halls is south of Dungeon and west of Pit. Pit is south of Harrows. Harrows is east of Dungeon and south of Caverns. Dungeon is east of Passage and south of Abyss. Passage is south of Abattoir. Abbattoir is west of Abyss and north of Passage. Abyss is west of Caverns. After looking: try listing exits. Example: ** The Gnome's Holiday - A full example of emphasized objects, compassless directions, and conversation topics. We'll create a slightly longer scenario with several locations and a simple puzzle, to demonstrate the full potential of Keyword Interface. This story has "keywords required" set to true, so it begins with a menu that helps players calibrate keywords. We implement an extremely simple conversation system to demonstrate emphasized topic words. Note that a real conversation system would need to be much more robust and elaborate. We'll also create a variation on the exits verb to show our compassless exits. *: "The Gnome's Holiday" Include Keyword Interface by Aaron Reed. Use American dialect. Topic keyword highlighting is true. Parser highlighting is true. Keywords required is true. After printing the banner text: say "First time players type ABOUT for more instructions.". Section - Conversation keyword-asking is an action applying to one thing. Understand "[a speakable]" as keyword-asking when the number of other people in location > 0. Carry out keyword-asking: let subject be a random other person in the location; say "[message of noun][paragraph break]". A speakable is a kind of thing. A speakable has some text called the message. Instead of doing anything other than keyword-asking to a speakable: say "That's merely a topic of conversation.". Does the player mean doing something other than keyword-asking to a speakable: it is very unlikely. Section - Exits Every room has some text called the exits text. First carry out listing exits: unless the exits text of location is "": say the exits text of location; say line break; stop the action. After looking: try listing exits. Section - Instructions Understand "about" as requesting the about text. Requesting the about text is an action out of world applying to nothing. Carry out requesting the about text: carry out the showing the keyword introduction text activity. Section - Game Gnome's Garden is a room with description "Brightly pastel flowers dot this well-kept garden, bordering a button-cute shack with whimsical stylings on the edge of the river, which is spanned here by a [drawbridge]." and exits text "A [d]path[x] of cherry-colored bricks winds off towards some distant hills, while the [if shack door is open][d]door[x] to the gnome's shack stands open[else]door to the gnome's shack is closed[end if][if drawbridge is open]. The lowered drawbridge spans the river to a treasure-strewn [d]wonderland[x][end if].". Understand "path" as west when location is Gnome's Garden. A stone table is a keywordless fixed in place supporter in Gnome's Garden. On the table is a copy of the Daily Gnomon with description "You can't read gnomish, but you can make a great gnocchi." The keyword of the Daily Gnomon is "copy". The button-cute shack is scenery in Gnome's Garden. Instead of entering shack, try going north. The shack door is a closed locked undescribed door with keyword "door". It is north of Gnome's Garden and south of Cozy Shack. The can't go through undescribed doors rule is not listed in any rulebook. Instead of going inside in Gnome's Garden, try going north. The drawbridge is a closed unopenable door. "[if closed]The drawbridge is raised, allowing passage by a steady stream of tiny steamboats, but preventing access to the treasure-strewn wonderland on the other side of the river[else]Wee steamboats queue impatiently behind the lowered drawbridge[end if].". It is east of Gnome's Garden and west of the Treasure-Strewn Wonderland. The description of drawbridge is "[if closed]If only you could find a way to lower it and cross the river![else]The treasure-strewn wonderland across the river awaits![end if]". The cherry-brick path is a backdrop. It is everywhere. Understand "cherry/cherry-colored/colored" as path. Golden Pasture is a room with description "The grass here is thick and heavy, sparkling with gold and amber hues." and exits text "Only the [d]path[x] back to the garden is clear." Golden Pasture is west of Gnome's Garden. Understand "path" as east when location is Golden Pasture. The gnome is a person in Golden Pasture. "A [gnome] perches on a checkered toadstool here, stroking his beard in relaxed contentment." The description is "Dressed in brightly colored clothes, he has the cheerful air of someone on holiday.". After examining the gnome, say "You could ask him about his [t]dragon[x], the [t]weather[x], or the [t]drawbridge[x].". A pet dragon creature is a female animal in Golden Pasture. "Clinging anxiously to the gnome's cap is a tiny bronze [o]creature[x].". The description is "Looking closer, you see she is a beautiful baby dragon. She regards you [if we have keyword-asked the personality topic]with a friendly twinkle in her eye[else]fearfully, clutching the gnome's hat with an almost comically tight grip[end if]." The dragon topic is a speakable with message "'You like her?' the gnome says fondly, petting the dragon which watches you nervously. 'She's named [t]Quinnabel[x].'". The Quinnabel topic is a speakable with message "'Found her in an old mushroom mine,' the gnome says, warming to his subject. The dragon sniffs you tentatively. 'She's got quite a [t]personality[x].'". The personality topic is a speakable with message "'Oh, she's shy at first, but she'll warm up to you right away if you let her.' And sure enough, the dragon finally seems to take a liking to you, and purrs contentedly as you scratch it behind the ears.". After keyword-asking the personality topic for the first time: say "'See, you're not such a bad sort,' the gnome says. 'Why don't you take this key and see to that drawbridge yourself.' And he hands you a scuffed silver key (oversized even for you)."; move silver key to player. The silver key unlocks the shack door. The drawbridge topic is a speakable with message "'Hrmph,' the gnome mutters, crossing his arms defiantly, 'I'm supposed to be on vacation.'". The weather topic is a speakable with message "'Looks like another day of beautiful sunshine again,' he grumbles.". The gnome carries dragon topic, Quinnabel topic, personality topic, drawbridge topic, and weather topic. The description of Cozy Shack is "Strewn with bric-a-brac; your eyes are drawn immediately to the prominent [lever] on the riverward wall.". The exits text of Cozy Shack is "The only place to go is back [outside].". Instead of going outside in Cozy Shack, try going south. Instead of exiting in Cozy Shack, try going south. A lever is an undescribed device in Cozy Shack. Instead of pushing or pulling the lever, try switching on the lever. After switching on the lever: now drawbridge is open; say "You hear a splash and a creak from outside the shack.". After going to Treasure-Strewn Wonderland for the first time: say "You enter the land of treasure. Congratulations!"; end the story saying "You have won". Understand "wonderland" as east when location is Gnome's Garden. Test me with "copy / drawbridge / door / open door / path / x path / gnome / drawbridge / dragon / Quinnabel / personality / path / unlock door / open it / exits / door / pull lever / out / wonderland".