-
Notifications
You must be signed in to change notification settings - Fork 17
Vari verbs
A vari-verb is a command that covers a set of verbs; the verbs are so similar that usually you do not care which the user typed, but occasionally you do.
An example may make that clearer. The "Hit" command handles ATTACK GOBLIN, PUNCH GOBLIN, KICK GOBLIN and MURDER GOBLIN (and others). In most games, killing NPCs is not allowed, and a simple response can handle that, so there is one command to cover all that. But perhaps you want a different response to each.
The vari-verbs all use the standard command script, which passes the work to the item, invoking an attribute function with the same name; in this case, a function called "hit". It is passed a dictionary, and the dictionary has various attributes:
- item: This item
- secondItem: Another item involved; usually
undefined
- char: The character doing the action; normally the player but not always
- multiple:
true
if the command is for more than one item; eg EAT CAKE AND BUN - verb: The verb the player typed (converted to lower case)
This is the same as most of the other simple command verb-noun commands, by the way, except "verb" is usually not set.
Here is a simple example.
eat:function(options) {
msg("You think about whether you should " + options.verb + " the sandwich, but decide to save it for later.")
return false
},
It has some issues. The command will accept PARTAKE OF SANDWICH or PARTAKE SANDWICH, but "... you should partake the sandwich..." is not great English. I would suggest you are better detecting what the verb is, and responding to it. For example:
drink:function(options) {
if (["quaff", "guzzle", "knock back", "swig", "swill", "down", "chug"].includes(options.verb) {
msg("You knock back the beer in one!")
}
else {
msg("You taste the beer... Not great, but not bad. You drink a couple more mouthfuls.")
}
return true
},
You would want code in there that somehow disposes of the drink too in the first case, and allows taking another drink in the second case, but it illustrates the technique here. You might also want to code it so it can handle NPCs too.
You could give a vari-verb its own custom script. If you do, be aware that the objects list contains the item(s) first, then the verb.
Or you could just disable the vari-verb command altogether, and implement each verb variant as its own command. This is what the RPG library does with the various attack verbs.
- Eat:eat|feed on|feed|partake of|partake|dine on|dine|nibble|consume|swallow|ingest
- Drink:drink|imbibe|quaff|guzzle|knock back|swig|swill|sip|down|chug|consume|swallow|ingest
- Hit:attack|strike|hit|kick|hurt|fight|punch|murder|kill|slaughter
- Clean:clean|rub|dust|polish|shine
Note that the "Ingest" command handles verbs common to EAT and DRINK, passing the responsibility to drink or eat as it deems appropriate.
Creating your own vari-verb is just a case of setting up the regular expression and "objects" list for you command in the right way.
new Cmd('Clean', {
regexes:[{regex:/^(clean|rub|dust|polish|shine) (.+)$/, mod:{reverse:true}}],
objects:[
{scope:parser.isPresent},
{special:'text'},
],
// ...
Tutorial
- First steps
- Rooms and Exits
- Items
- Templates
- Items and rooms again
- More items
- Locks
- Commands
- Complex mechanisms
- Uploading
QuestJS Basics
- General
- Settings
- Attributes for items
- Attributes for rooms
- Attributes for exits
- Naming Items and Rooms
- Restrictions, Messages and Reactions
- Creating objects on the fly
- String Functions
- Random Functions
- Array/List Functions
- The
respond
function - Other Functions
The Text Processor
Commands
- Introduction
- Basic commands (from the tutorial)
- Complex commands
- Example of creating a command (implementing SHOOT GUN AT HENRY)
- More on commands
- Shortcut for commands
- Modifying existing commands
- Custom parser types
- Note on command results
- Meta-Commands
- Neutral language (including alternatives to "you")
- The parser
- Command matching
- Vari-verbs (for verbs that are almost synonyms)
Templates for Items
- Introduction
- Takeable
- Openable
- Container and surface
- Locks and keys
- Wearable
- Furniture
- Button and Switch
- Readable
- Edible
- Vessel (handling liquids)
- Components
- Countable
- Consultable
- Rope
- Construction
- Backscene (walls, etc.)
- Merchandise (including how to create a shop)
- Shiftable (can be pushed from one room to another)
See also:
- Custom templates (and alternatives)
Handing NPCs
- Introduction
- Attributes
- Allowing the player to give commands
- Conversations
- Simple TALK TO
- SAY
- ASK and TELL
- Dynamic conversations with TALK TO
- TALK and DISCUSS
- Following an agenda
- Reactions
- Giving
- Followers
- Visibility
- Changing the player point-of-view
The User Experience (UI)
The main screen
- Basics
- Printing Text Functions
- Special Text Effects
- Output effects (including pausing)
- Hyperlinks
- User Input
The Side Panes
Multi-media (sounds, images, maps, etc.)
- Images
- Sounds
- Youtube Video (Contribution by KV)
- Adding a map
- Node-based maps
- Image-based maps
- Hex maps
- Adding a playing board
- Roulette!... in a grid
Dialogue boxes
- Character Creation
- Other example dialogs [See also "User Input"]
Other Elements
- Toolbar (status bar across the top)
- Custom UI Elements
Role-playing Games
- Introduction
- Getting started
- Items
- Characters (and Monsters!)
- Spawning Monsters and Items)
- Systema Naturae
- Who, When and How NPCs Attack
- Attributes for characters
- Attacking and guarding
- Communicating monsters
- Skills and Spells
- Limiting Magic
- Effects
- The Attack Object
- [Extra utility functions](https://github.com/ThePix/QuestJS/wiki/RPG-Library-%E2%80%90-Extra Functions)
- Randomly Generated Dungeon
- Quests for Quest
- User Interface
Web Basics
- HTML (the basic elements of a web page)
- CSS (how to style web pages)
- SVG (scalable vector graphics)
- Colours
- JavaScript
- Regular Expressions
How-to
Time
- Events (and Turnscripts)
- Date and Time (including custom calendars)
- Timed Events (i.e., real time, not game time)
Items
- Phone a Friend
- Using the USE verb
- Display Verbs
- Change Listeners
- Ensembles (grouping items)
- How to spit
Locations
- Large, open areas
- Region,s with sky, walls, etc.
- Dynamic Room Descriptions
- Transit system (lifts/elevators, buses, trains, simple vehicles)
- Rooms split into multiple locations
- Create rooms on the fly
- Handling weather
Exits
- Alternative Directions (eg, port and starboard)
- Destinations, Not Directions
Meta
- Customise Help
- Provide hints
- Include Achievements
- Add comments to your code
-
End The Game (
io.finish
)
Meta: About The Whole Game
- Translate from Quest 5
- Authoring Several Games at Once
- Chaining Several Games Together
- Competition Entry
- Walk-throughs
- Unit testing
- Debugging (trouble-shooting)
Releasing Your Game
Reference
- The Language File
- List of settings
- Scope
- The Output Queue
- Security
- Implementation notes (initialisation order, data structures)
- Files
- Code guidelines
- Save/load
- UNDO
- The editor
- The Cloak of Darkness
- Versions
- Quest 6 or QuestJS
- The other Folders
- Choose your own adventure