-
Notifications
You must be signed in to change notification settings - Fork 17
Styling with the text processor
Styling just changes the appearance of the text, not its content. You can also do this with HTML/CSS, but for short sections within a paragrap this is easier and less typing. If you want to change the whole paragraph, you are better off using a CSS class with the msg
function.
Here is a simple example of styling text:
This text has {i:a section} in italic.
directive | effect | example |
---|---|---|
i | italic | example |
b | bold | example |
u | underlined | example |
s | strike-through | |
code | mono-spaced font | example |
sup | superscript | example |
sub | subscript | example |
huge | 200% the size | * |
big | 150% the size | * |
small | 80% the size | * |
tiny | 60% the size | * |
smallcaps | small capitals | * |
* The Github wiki software does not allow some styles to be displayed.
Use cap
to capitalise the first letter of the text, or title
to capitalise the first letter of every word - all other letters will be unchanged. Behind the scenes these use sentenceCaseForHTML
and titleCaseForHTML
; for details of the implications see here.
User upper
or lower
to change every latter to upper case or lower case respectively.
You can also use "colour" (or "color") and "back" to set the foreground and background colour, together with a colour.
This text has {colour:red:some of it} in red.
If you want to go a bit more extreme, use the "rainbow" directive, which turns every character a different character. The simple version uses the default list, but you can provide your own list to suit the colour scheme of your page (note that you cannot nest other directives or HTML code within a rainbow directive).
Some text {rainbow:with some quite colorful writing}.
Some text {rainbow:red:blue:with some not so varied colour}.
Colours must be either standard web colour names or hexadecimal triples; for more on both see here. Bear in mind about 5% of the population has some degree of colour-blindness, so choose your colours thoughtfully.
For all colour option, test what it looks like in dark mode. It may become unreadable! An alternative - if not straightforward - is to use class
and to set up the class in the CSS to change with dark mode.
You can blur text with the "blur" directive. This requires a number, the degree of blur. A value of 0 will look like normal, 2 or 3 are readable, higher than that, and it will be obscured.
{blur:3:If you were not so drunk you could read this}.
Use the "font" directive to change the font family.
This text has {font:sans-serif:some of it} in a plain font.
You need to be a little bit careful to ensure the user has the font on their computer. There is a page here which gives some suggested safe fonts.
Alternatively, you can download fonts from Google in the stylesheet. You should pick out all the fonts you need, then go to the list of families at the bottom, go to "Embed", then "Import" and get some text like this (in this example I am using two font families; Krona One and Trade Winds):
@import url('https://fonts.googleapis.com/css?family=Krona+One|Trade+Winds&display=swap');
Paste it into the top of the style.css file, and you are good to go.
Use the class directive to have the section of text in a given CSS class (which should be defined in a .css file somewhere, probably style.css). The advantage of this for colours is that your CSS can include a definition for dark mode.
To highlight speech, and perhaps differentiate between different speakers, you can put spoken text inside a dialogue
directive, which will also add quotation marks.
This has three modes. All of these put quote marks around the text for you. By default single quotes are used, but you can modify to your liking in the settings. For French style, for example, it would look like this.
settings.openQuotation:"<<",
settings.closeQuotation:">>",
If the first parameter starts with a dot, this is taken as a CSS class, and this will be applied to the rest of the parameters. In this example the class "my-css-class" is used. If the class does not exist, the text will appear, but no styling will be applied.
"Kyle says; {dialogue:.my-css-class:Hello!}"
In the second mode, you specify the styling in the directive. For the first parameter, if it includes "i", the text will be in italic, if there is a "b" it will be in bold, if a "u" it will be underlined. The second parameter is the colour, which can be any HTML colour. These two examples both set the text to be cyan; the second also sets it to be italic and bold.
"Kyle says; {dialogue::cyan:Hello!}"
"Kyle says; {dialogue:ib:#00ffff:Hello!}"
You can also associate the styling with an object; this allows you to consistently colour-code the NPCs in your game. To do this, specify a parameter (as discussed here), and Quest will use its "dialogueStyle" to get the styling, which must be in the standard CSS format. In this example, Kyle's "dialogueColour" is set to magenta, Lara's to orange and italic. The text is then set to use the object set to "char" in the parameters.
w.Kyle.dialogueStyle= 'color:#ff00ff;'
w.Lara.dialogueStyle= 'color:orange;font-style:italic;'
msg("Kyle says; {dialogue:char:Hello!}", {char:w.Kyle})
msg("{dialogue:char:And hello to you!} replies Lara.", {char:w.Lara})
Use the encode
directive to translate text into another character set for messages in exotic languages. The directive requires two hexadecimal numbers, the first unicode character for upper case and lower case letters. You need a continuous block of 26 unicode characters for each set (or use the same for both upper and lower case).
Some examples:
Some text in Greek: {encode:391:3AC:The quick brown fox jumped over the lazy dog}.
Some text in Cyrillic: {encode:402:431:The quick brown fox jumped over the lazy dog}.
Some text in Armenian {encode:531:561:The quick brown fox jumped over the lazy dog}.
Some text in Devanagari: {encode:904:904:The quick brown fox jumped over the lazy dog}.
Some text in Thai {encode:E01:E01:The quick brown fox jumped over the lazy dog}.
Some text in Tibetan {encode:F20:F20:The quick brown fox jumped over the lazy dog}.
Some text in Khmer {encode:1780:1780:The quick brown fox jumped over the lazy dog}.
Some text in Javan {encode:A985:A985:The quick brown fox jumped over the lazy dog}.
Some text in Nko {encode:7C1:7C1:The quick brown fox jumped over the lazy dog}.
Please use responsibly; these character sets are a part of some people's culture.
The command
directive (or just cmd
) will add a hyperlink; when clicked it will pass the command to the parser.
{cmd:get boots}
{cmd:drop hat:drop the hat}
You can use exit
and page
as synonyms, to ease conversion from Quest 5.
You can link to other web pages with the link
directive. The first parameter is the text that will appear on the page, the second is the address. Note that the page will open in a new tab, so the user will not lose their game if she clicks on it!
Learn more about Quest 6 {link:here:https://github.com/ThePix/QuestJS/wiki}.
If you link to a file in your game, I suggest putting the file in either the game folder or another, dedicated folder. The Text Adentures web site can occasionally get confused about which is the primary HTML file; if index.html is the only one in the top directory it should know that is the one.
An example of this is described for the HINT command here.
The img
directive can be used to include an image. By default, this should be in the images folder (settings/images, unless you have changed it), however, if the filename has a forward slash, Quest will assume you have included the path yourself. You can optionally include a title (as in the example below) and "alt" text (not included in the example).
{img:box.png:An image of a box}
You can have a link in your text that will toggle a box of text. This could be used to offer a kind of glossary - click on a term to see a definition. The popup
directive has two parts, the first being the link text and the second being the text to display.
There is a sizeable {popup:desert:A desert is a large dry area.} to the west.
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