Skip to content

Settings

ThePix edited this page Sep 16, 2020 · 38 revisions

The settings.js file gives the author the opportunity to customise the game to his or her liking.

In fact, there are two files, one in "lib" where the defaults are set, and one in "game" for authors. You just need to include the values you want to change in your own settings.js file.

Settings are all attributes of the settings object, and you can add also your own custom attributes - but be aware that none of these attributes are saved when the player saves their game, so they should not be used to track game state (i.e., in general they should never change during play; the only exception might be player customisation of the interface).

The values in the code snippets below are the defaults, except where noted.

Meta-Data

The first section is a set of constants for meta-data.

settings.title = "A First Step..."
settings.author = "The Pixie"
settings.subtitle = "An example game for Quest 6"
settings.version = "1.0"
settings.thanks = ["Kyle", "Lara"];
settings.warnings = 'No warning relevant for this game.'

Basic info about your game. Note that the first two are required (there is no default), and these are the only setting you must have in "settings.js". The "thanks" setting is an empty array by default; it is shown here with two entries to show how it should be formatted.

The "warnings" setting is useful for players who might have issues with certain games (for example, a description of a lavish meal might upset someone with an eating disorder, and graphics depictions of violence or sex should definitely be mentioned). Players can choose to use the WARNING command to see this information. You may also want to include further warnings that show automatically when your game starts in more extreme cases. I appreciate this is somewhat subjective.

Side Pane

settings.panes = 'Left'
settings.compass = true
settings.divider = "div.png"
settings.statusPane = "Status"
settings.statusWidthLeft = 120
settings.statusWidthRight = 40
settings.status = [
  function() { return "<td>Health points:</td><td>" + game.player.hitpoints + "</td>"; },
]
settings.inventories = [
  {name:'Items Held', alt:'itemsHeld', test:util.isHeldNotWorn, getLoc:function() { return game.player.name; } },
  {name:'Items Worn', alt:'itemsWorn', test:util.isWorn, getLoc:function() { return game.player.name; } },
  {name:'Items Here', alt:'itemsHere', test:util.isHere, getLoc:function() { return game.player.loc; } },
]

The panes value can be set to "Left", "Right" or "None". If set to anything else, the panes will be hidden, but still get drawn. Setting the value to "None" stops them getting drawn at all, so will be faster (though doubtful anyone will notice).

The compassPane value turns the compass on or off.

The statusPane value sets the name of the status pane. Set to false to turn it off. The status values will be set out in a table to keep values neatly aligned, use statusWidthLeft and statusWidthRight to adjust the column widths.

The "status" value is an array of functions, where each function should return an HTML string defining two TD elements, the name and the value (this will get inserted into a TR, so the <tr> tags should not be included).

The "inventoryPane" value is an array of dictionaries. Set to an empty array to turn off inventories.

Main Pane

These are pretty self-explanatory.

settings.textInput = true       // player types commands
settings.cursor = ">"           // prompt for the commands
settings.cmdEcho = true         // input commands are repeated on screen
settings.typewriter = false     // if true there is a delay between each character when text is printed
settings.typewriterDelay = 25

This less so:

settings.roomTemplate = [
  "{hereDesc}",
  "{objectsHere:You can see {objects} here.}",
  "{exitsHere:You can go {exits}.}",
]

This defines what the player sees on entering a room (or typing LOOK). Each entry in the array will be a paragraph of text, and they all use the text processor. The first line gives the description for the room (the text processor directive hereDesc should not be used in any other context). The second line is a list of objects here, the third line a list of possible exits (but the text processor directives mean that these are only used if there is something to list).

This alternative adds the room name as a heading, allows TERSE/BRIEF and VERBOSE to control the room description, and has no exit list.

settings.roomTemplate = [
  "#{cap:{hereName}}",
  "{terse:{hereDesc}}",
  "{objectsHere:You can see {objects} here.}",
]

Game play settings

settings.failCountsAsTurn = false
settings.lookCountsAsTurn = false
settings.saveDisabled = false
settings.splitLinesOn = "<br>"
settings.convertNumbersInParser = true
settings.maxUndo = 10
settings.moneyFormat = "$!"

By default Quest 6 does not count it as a turn if the player types something that the parser cannot understand (which is different to when the parser understands but the character cannot do the action). Also by default, Quest 6 also does not consider LOOK to take a turn. The first two allow you to change that.

You also have the option to disable saving.

Quest 5 considers "<br>" in a string to be a line break. Quest 6 does not work quite the same so you can have it use whatever you want.

If you use COUNTABLEs, the player can type GET FIVE BRICKS. The parser convert the word "FIVE" to the digit "5" (and any number from 0 to 20), which the COUNTABLE system can then handle. If "convertNumbersInParser" is set to false, the player will have to type the digits, not the word for the number. However, you may not want that if you have items with numbers in their names (though there are ways around that using the items "regex" attribute). Commands will process faster if this is set to false (say around 20% faster, though on my system they take around 2 ms, so not noticeable anyway).

When "debug" is true, some extra commands are available. Set to false before releasing!

"maxUndo" is the maximum number of times the player can undo (i.e., by default Quest 6 remembers the last ten turns). Set to zero to disable.

"moneyFormat" is clearly the format for money

There are also various settings connected to specific features, but these are discussed in the pages on about the relevant feature and better read in that context.

File settings

For all these settings, filenames should be given without the path or extension.

settings.lang = "lang-en"      // Set to the language file of your choice
settings.customExits = false      // Set to the filename to use otherwise
settings.libraries = ["saveload", "text", "io", "command", "defaults", "templates", "world", "npc", "parser", "commands"]
settings.customLibraries = []
settings.files = ["code", "data"] // Additional files to load

"lang" allows you to set the language. "customExits" allows you to override the normal "north", "south", set it to the name of the file in your game folder.

"customLibraries" allows you to add custom libraries to your game. A library is a set of files (or just one) that might be used across multiple games, possibly shared with other authors. Each entry in the array should be a dictionary with a "folder" entry, a string, and a "files" entry, an array of filenames.

The "files" array is an array of files specific to your game. By convention, "code.js" has functions, commands and other stuff, while "data.js" has all the objects, but you may want to add other files (I like to have one for NPCs for example).

Date and time

If you want to track time, you may want to investigate what the options mean here.

  settings.dateTime = {
    year:"numeric",
    month:"short",
    day:"2-digit",
    hour:"2-digit",
    minute:"2-digit",
    secondsPerTurn:60,
    locale:'en-GB',
    start:new Date('February 14, 2019 09:43:00'),
  }

The most important one is the start time, which you can set like this:

settings.dateTime.start = new Date('April 14, 2387 09:43:00')

Use the getDateTime() function to get the current game time as a string (game.elapsedTime is used to record the number of seconds that have passed in game since the game started).

Note that Quest 6 can handle dates about a quarter of a million years into the future or past, beyond that it will become less and less accurate (but may get confused by changes to the calender, for example with the missing days of 1752!).

setup and intro

These are used when the game starts, if set. "setup" must be a function, and "intro" a string. Note that "intro" is printed first so the player has something to read while "setup" runs.

To see how to create a dialog box at start up for character creation, see here.

Development settings

Useful when writing your game.

settings.debug = true
settings.test = false
settings.shortcutCommand = 'test'

When "debug" is true some extra commands are added to your game (see here).

Set "test" to true to allow unit testing (see here).

The "shortcutCommand" fires when the player presses 0 on the number pad. By default it runs the unit tests, but can be set to anything. If you are testing by using a walk-though called "wt1" you could set it to 'wt wt1', then you just need to press one button to run the walk-through.

Tutorial

QuestJS Basics

The Text Processor

Commands

Templates for Items

See also:

Handing NPCs

The User Experience (UI)

The main screen

The Side Panes

Multi-media (sounds, images, maps, etc.)

Dialogue boxes

Other Elements

Role-playing Games

Web Basics

How-to

Time

Items

Locations

Exits

Meta

Meta: About The Whole Game

Releasing Your Game

Reference

Clone this wiki locally