-
Notifications
You must be signed in to change notification settings - Fork 18
Command results
A command should return a result that indicates how successful it was. First, some terms so we know what we are talking about.
Verbs are used by commands; they are attributes of objects, for example the "take" attribute is used by the TAKE command. They are called verbs, following the convention of Quest 5 somewhat. A verb should return true
if it was successful and the game world changed (the item was picked up), and false
if it did not happen, and the world was not updated (the item could not be picked up).
The important point is that if a verb returns false
, the game will not update the world (for example the panes on the left) and turnscripts will not run (unless the command involves multiple items and another item returns true).
A text adventure involves two people. One is sat at a computer typing commands; this is the user. The other lives in the game world, and acts according to the commands the user types. This is the player character, or PC for short or more often just player.
Some commands do not affect the player. If the user types HELP, the player is not affected, and knows nothing about the command or response, and for that reason the response is printed using the metamsg
function to differentiate it. This is a meta-command. This is also a consideration with regards to the result of a command.
The result of a command should be an integer (if a Boolean is used, a debug message will be given as a warning), but should be indicated by a constant. If the user attempts a command with multiple objects, the returned result should be the best, so if any of them on their own would rate SUCCESS, then the overall result in SUCCESS.
There are four results Quest will recognise. Each of these is set to be a non-zero integer.
The command was a success (in some sense) and the game world has changed. The game world will be updated and turnscripts will run.
The command was a success; however the game world has not changed and in game no time has passed, so turnscripts should not be run. Meta-commands such as HELP, TERSE and SPOKEN are obvious examples.
I have chosen to make LOOK, INVENTORY and MAP return this on the basis that the player character should know where she is; the commands serve to jog the user's memory, not to have the player character do something. Set TURNSCRIPT_AFTER_LOOK
to true in settings.js otherwise.
The command was understood but the user is trying to do something that is not allowed, such as go though an exit that does not exist, put an item in something that is not a container.
I have taken the view that the player character knows there is no door, knows the item is not a container, so no time passes in game, and so turnscripts should not run, no time has passed.
You can change that by setting FAILS_COUNT_AS_TURNS
to true
in settings.js.
More borderline examples are trying to go through a locked door; does the PC spent time trying the door to find it is locked? It is arguable.
The parser has failed to understand what the user typed. The game world is not changed, the game is not updated and turnscripts are not run. Generally commands should not return this - it is used when no command was found.
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