Skip to content

Commenting your code

ThePix edited this page Mar 22, 2023 · 1 revision

It is often a good idea to add comments to your code so that when you come back to it three months later you can remember what you did and why you did it.

JavaScript - and hence QuestJS - support two types of comments.

Line comments

Line comments start with two slashes, and continue to the end of the line.

  player.score += 5  // he did well, so increase the score

Multi-line comments

Multi-line comments start with a slash and an asterisk, and continue until the reverse, an asterisk and a slash.

/*
This function does some useful stuff
*/
function doStuff(arg1, arg2) {
  ...
}

Despite the name, multi-line comments can be used on a single line, and even in the middle of a line. In this example, a multi-line comment has been used to hide the second parameter in the function call from Quest.

doStuff("lounge"/*, "A curious room"*/)

Comments when debugging

This illustrates an important use of comments - to temporarily hide code while you try to debug. If something is interfering with your system, try commenting out blocks of code - usually whole objects - to be sure they are not the problem.

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