-
Notifications
You must be signed in to change notification settings - Fork 18
Template ‐ WEARABLE
This template allows you to add clothing, jewelry, backpacks, etc. to your game.
Note that using the WEARABLE template automatically includes the TAKEABLE template for your object.
Garments can be assigned to layers and slots. Slots are where the item is worn. Each slot is a string, for example “head”. At this point, we need to make a design decision - how are we going to divide the body up? This is up to you. For simplicity, you might say: feet, lower, upper and head. Trousers cover the lower body, so in the wear slots section, add “lower”. However, it is up to you - you just need to be consistent!
As well as slots, clothing has layers. Trousers might go in layer 2, whilst underwear obviously worn underneath might go in layer 1. The player will be unable to put underpants on if he is already wearing trousers, but could take the trousers off, then put the underwear on, then put the trousers back on.
createItem("underwear", WEARABLE(1, ["lower"]), {
loc:"bedroom",
pronouns:lang.pronouns.massnoun,
examine:"Clean!",
});
createItem("jeans", WEARABLE(2, ["lower"]), {
loc:"bedroom",
pronouns:lang.pronouns.plural,
examine:"Just some old jeans",
});
Garments can occupy more than one slot, so overalls could be set to have both "lower" and "upper", but only one layer.
createItem("jumpsuit", WEARABLE(2, ["upper", "lower"]), {
loc:"bedroom",
examine:"Bright orange",
});
And any garment with no slots can be worn without restrictions. And you may choose to do this for all the garments in your game, and not worry about what what is worn where!
createItem("helmet", WEARABLE(), {
loc:"tower_of_power",
examine:"This steel helm is clearly magical. Or cursed.",
});
Layer zero is special; it is effectively all layers. Say you have a pair of shorts that cannot be worn under trousers or over underpants, you can set its layer to 0.
You can add "testWear" and "testRemove" functions to an object; these will run before a garment is worn or removed; if they return false
the action is aborted. They should print a message saying why in that case.
This example is for a spacesuit. If the room is has air, it can be taken off. Otherwise, a message is printed and false
returned.
testRemove:function(options) {
if (isRoomPressured(w[optionschar.loc])) return true
msg("{nv:char:start:true} to unseal {pa:char} spacesuit... There is a hissing sound, and suddenly {nv:char:be} struggling for breath. Quickly, {nv:char:seal:true} it up again. Perhaps taking a spacesuit off in a vacuum is not such a good idea?", options)
return false
}
You can add "afterWear" and "afterRemove" functions to an object; these trigger after the object is put on or taken off, and take the character involved as an attribute.
afterWear:function(options) {
if (options.char === w.Patch && !this.patchFlag) {
msg("Mandy looks at Patch in his new hat. 'You look cool!'")
this.patchFlag = true
}
if (options.char === player && !this.playerFlag) {
msg("Mandy decides she likes the hat; it makes her feel very... Bohemian she decides. It is a shame there is no mirror here.")
this.playerFlag = true
}
},
Some attributes have getters too; by default they just return the attribute. It is occasionally useful to override the getter to make the item dynamic - perhaps the slots change after a shirt gets ripped.
Attribute | Getter | Comment |
---|---|---|
wearable | Always true
|
|
worn | getWorn() |
true if worn, obviously |
slots | getSlots() | See above |
wear_layer | See above | |
armour | getArmour() | Defaults to zero |
testWear(char) | See above | |
testRemove(char) | See above | |
msgWear | Optional | |
msgRemove | Optional |
You can call getWearing
on an NPC to get a list of garments.
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