-
Notifications
You must be signed in to change notification settings - Fork 18
The Output Queue
Deciding when something should get written to the screen is not trivial. The author might want a pause of so many seconds or have the player click to continue. There are text effects that take time to complete. Sounds may need to be coordinated with that too. To handle all this, Quest 6 uses a queue. When the game determines something is to be written it gets added to the end of the queue. Meanwhile, Quest is pulling items from the start of the queue as required to show on the screen.
The io.addToOutputQueue(data) function is used to add an item to the queue (usually via _msg), while io.outputFromQueue takes the next item, and handles it; if it is text, it is passed to io.print. The queue itself is io.outputQueue, and the system uses io.outputSuspended to flag that output should be temporarily stopped.
The errormsg and debugmsg functions bypass the queue, and directly use io.print, as the issue may be in the queue.
The items are dictionaries with various attributes:
action: What to do, should be one of those listed later
cssClass: The CSS class, defaults to "default-" plus the tag (eg "default-h2")
delay: How long to wait for, in seconds (only used for delay)
destination:An image can be sent to the named HTML element rather than the normal output
id: A unique sequential number assigned by Quest - do not set this yourself
height: Used by images
name: Name of the audio element to play (only for sound and ambient)
onclick: Text to give to the element's "onclick" attribute.
printBlank: Print even if there is no content (only for output)
src: As usual for HTML images
tag: HTML tag name to use for this element, defaults to "p"
text: The actual text
volume: How loud to play the sound (only for ambient)
width: Used by images
Effects use further attributes
The actions allowed are:
| action | input disabled | output suspended | next | comment |
|---|---|---|---|---|
| wait | y | y | n | Print a message, then wait for player click, calling io.waitContinue()
|
| delay | y | y | n | Optionally print a message, then wait for delay seconds, before calling io.unpause()
|
| output | n | n | y | Print the text to screen using io.print, with itself as parameter |
| clear | n | n | y | Empty the #output element |
| ambient | n | n | n | Stop all current sounds, start name, looping |
| sound | n | n | n | Start name |
| effect | n | n | n | Calls its own effect function attribute, with itself as parameter |
| func | n | n | ? | Call the "func" attribute as a function; will go to next if the function returns true
|
Usually after one item is printed, it calls io.outputFromQueue (noted under the "next" column in the table). However, if an action sets io.outputSuspended this will cause io.outputFromQueue to terminate before doing anything. Thus, if the author has some text printed, then a pause, then more text, as each line of text is printed, it calls io.outputFromQueue. When it gets to the pause, however, it does not, instead setting up a time out. The timeout then calls io.forceOutputFromQueue, which unsets io.outputSuspended before calling io.outputFromQueue and the rest of the text is printed.
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
respondfunction - 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