-
Notifications
You must be signed in to change notification settings - Fork 17
Tutorial 7 ‐ Locks
... Continued from More items.
So we have that locked door from the kitchen to the garage. Let us say that there is a charger for the torch there, if the player can find the key.
You cannot lock or unlock an exit during the game because the exit is not really a thing; it is not a location or item in the game world. The user is going to type UNLOCK DOOR, so it needs to be the door that gets unlocked. Also, exits are not saved, so their state has to be changed in a room or item.
Quest 6 has a LOCKED_WITH template we can use with the door, however, locked doors are tricky things, as they can be accessed from either side - they straddle two room and have to control the exits from both. So let us look at locking a container first.
We will start with a locked container; the glass cabinet we put n the lounge earlier. The cabinet is openable, so CONTAINER is sent true
. We also give it the LOCKED_WITH template. This requires the name of the key (or an array of names if more than one). I have also flagged it as transparent, so the player can see what is inside even when it is closed.
createItem("glass_cabinet", CONTAINER(true), LOCKED_WITH("cabinet_key"), {
examine:"A cabinet with a glass front.",
loc:"lounge",
transparent:true,
})
You can use the KEY template for the key, though behind the scenes it does nothing more than the TAKEABLE template except give the item a key icon.
createItem("cabinet_key", KEY(), {
loc:"garage",
examine: "A small brass key."
})
So now, about that door... We need an object that is in two rooms, and when locked or unlocked it changes exits in both rooms. Fortunately, Quest 6 has a template that does all that for us.
So here is a key and a door:
createItem("garage_door", LOCKED_DOOR("garage_key", "kitchen", "garage"), {
examine: "The door to the garage.",
})
createItem("garage_key", KEY(), {
loc:"lounge",
examine: "A big key.",
})
Behind the scenes, the door has both the OPENABLE and LOCKED_WITH templates, plus more inside the LOCKED_DOOR template. This requires the name of the key (or an array of names), followed by the name of the two locations. You can also give two aliases (one from each room) if you choose.
The door object must be after the rooms in your file (and obviously you need exits from the rooms to each other). By default the door is scenery.
Continued in Commands...
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