Handling regions
A region in this context is a collection of locations that have some basic similarity. One region could be a cave system, while another is a swamp and a third is a castle. Features of a region tend to be the same, so sounds and smells default to the same, and there may be some identical background items too.
This is all optional, but will make for a more polished game. Even for simple games setting up a single region allows you to handle the players doing EXAMINE WALLS in a slick manner.
I suggest splitting your game up into different files, with one file per region, but the important point is to have all locations for one region collected together. And at the start of that file, or that section of the file, you set up the region.
Here is an example that will set up a region called "castle":
setRegion('castle', {
smell:'There is a faint musty smell, with just a hint of polish.',
listen:'It is eerily quiet...',
floor:"The floor is wooden, and well-polished.",
wall:"The walls are all paneled in wood.",
ceiling:"The ceiling is white, with simple decorations along each side.",
})
All locations that are created subsequent to this (up until you set up the next region) will have their "_region" attribute set to "castle". It also sets default SMELL and LISTEN responses for the locations in this region, and descriptions for generic items.
So now we need to create those generic items. You may need to add more for your game, but there really is very little to them. The BACKSCENE template does the work.
createItem("wall", BACKSCENE(), {
alias:"walls",
})
createItem("floor", BACKSCENE(), {
synonyms:["ground"],
})
createItem("ceiling", BACKSCENE(), {
})
A BACKSCENE item will only be there in a region that has a description set for it.
Sometimes you want one location in the region to be a bit different...
For LISTEN and SMELL, just give the location its own attribute.
You can also have descriptions for generic items in specific locations by giving the location an attribute named "examine_" plus the name of the item. For example:
createRoom("lounge", {
// ...
listen:'The clocks ticks...',
examine_wall:'A fine example of a feature wall.',
})
The way it will work for walls, for example, is Quest will check if the location's region has a "wall" attribute. If it does not, it will report that there is no wall here. If there is a "wall" attribute for the region, Quest will now look at the location, and see if it has an "examine_wall" attribute. If it does, it will either run the function or print the string. If it does not, it will use the "wall" attribute for the location's region.
Note that region data is not saved when the user saves the game - though the "_region" attribute of the location will be.
If you want to have dynamic descriptions, you can
- use text processor directives in the strings
- change the region attribute of the locations
- use examine addendum strings
An example of the first, with the text depending on an attribute of the player, is seen here:
setRegion('castle', {
smell: "{if:player:afterFire:Everything smells of smoke.:There is a faint musty smell, with just a hint of polish.}",
listen: "It is eerily quiet...",
floor: "{if:player:afterFire:The wooden floor has mostly survived, but is strew with ash.:The floor is wooden, and well-polished.}",
wall: "{if:player:afterFire:The wooden panels of the walls have burned to black ashes.:The walls are all paneled in wood.}",
ceiling:"{if:player:afterFire:The ceiling is a dirty grey, with patches of black.:The ceiling is white, with simple decorations along each side.}",
})
The second approach requires a dummy region. This is just like a normal region, except that there must be no locations defined after you create it before you create the next region.
setRegion('castleAfterFire', {
smell:'Everything smells of smoke.',
listen:'It is eerily quiet...',
floor:"The wooden floor has mostly survived, but is strew with ash.",
wall:"The wooden panels of the walls have burned to black ashes.",
ceiling:"The ceiling is a dirty grey, with patches of black.",
})
// Nothing here!!!
setRegion('castle', {
smell:'There is a faint musty smell, with just a hint of polish.',
listen:'It is eerily quiet...',
floor:"The floor is wooden, and well-polished.",
wall:"The walls are all paneled in wood.",
ceiling:"The ceiling is white, with simple decorations along each side.",
})
When the event happens, you need to change the "_region" attribute for each affected location. The advantage of this technique is that you can select which locations that is, rather than have them all affected.
The slick way to do it is put them in a list, and iterate.
for (const el of [w.lounge, w.drawing_room, w.study]) el._region = 'interiorAfterFire'
You can give a location a string that will get added to the end of the description for a BACKSCENE item. The name of the attribute must be "addendum_examine_" plus the name of the item, for example "addendum_examine_wall".
Thus, if the player shoots the wall, you can do this:
currentLocation.addendum_examine_wall = 'There is a gun shot hole in the wall.'
There is a more complete example here.
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
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
- 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
- Following an agenda
- Reactions
- Giving
- Followers
- 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!)
- Attributes for characters
- Attacking and guarding
- Skills and Spells
- Limiting Magic
- Effects
- The Attack Object
- 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)
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
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