Walk throughs - ThePix/QuestJS GitHub Wiki
NOTE: The walk-though command is only available if settings.playMode
is set to "dev" in setting.js. Remember to set it to "play" before releasing your game.
Walk-throughs can be very useful when creating your game as they can get you past the bit of your game you have already done very easily. They can also be used for testing, but can lead to you only ever trying one route, so are limited and should be used with care.
You can have several walk-throughs in your game. Create a dictionary called "walkthroughs". Each entry is a walkthrough, i.e., an array of commands to be performed.
Here is a very simple example:
const walkthroughs = {
a:[
"n", "w", "n",
]
}
To use the walk-through, go into the game, and type WT . In the above example, that would be WT A (do not use numbers, either letters or words, the parser may get confused).
Use a dictionary rather than a string to handle menu options and questions. The "cmd" attribute should be the command. the "menu" attribute can be a string or number, or array of strings and numbers. Use numbers for menus and strings for questions.
const walkthroughs = {
a:[
"e",
"s",
{cmd:"talk to lara", menu:0},
{cmd:"talk to kyle", menu:[0, 2]},
],
}
Note that menu options start at zero.
To record a set of commands, use the transcript system.
Start recording with SCRIPT ON, and stop with SCRIPT OFF. To see the transcript, do SCRIPT WALK; the code will appear in a new tab. Copy-and-paste into your code, and modify as required (it defaults to "recorded" as a name).
Note that unlike the normal transcript, the walk-though transcript is reset by SCRIPT ON, is not affected by TRANSCRIPT CLEAR and is not saved to localStorage, so will be lost when you reload the page or navigate elsewhere. Commands that start SCRIPT or TRANSCRIPT are not recorded (they can cause your walkthrough to act strangely); this is controlled through lang.noWalkthroughRegex
, which you could modify to ignore other commands (or for other languages).
If you have disabled the command line, use these commands in the developer console:
saveLoad.transcriptStart()
saveLoad.transcriptEnd()
saveLoad.transcriptWalk()
When testing your game, you may find you want to run a walk-through a lot. To make that faster, there are three short-cuts.
Name | Short cut |
---|---|
a | alt-KeyPad0 |
b | ctrl-alt-KeyPad0 |
c | ctrl-KeyPad0 |
You need to have "num lock" on (and a keypad on your keyboard).
Once you have the first draft of your game, it can be useful to quickly get to one point in the game when you realise there is an error there that needs to be resolved. If you have a walk-through that gets you all the way to the end, you can very quickly do this by just commenting out the bits you do not want. The best way to do this is using a multi-line comment (/*
and */
), with an empty comment at the end. Thus, your walk-through might look like this:
const walkthroughs = {
a:[
"get hat",
"wear hat",
"x grass",
"smell",
"x box",
"read label",
"open box",
"get crowbar",
"remove hat",
"put it in box",
"close lid",
"crowbar shed",
"east",
"get torch",
"out",
"sw",
"turn on torch",
"down",
"turn on light",
/* */
]
}
The comment at the end does nothing, but if we insert a break part way though, it becomes the end of the comment. Say I have an issue inside the shed, I can comment out everything after getting to that point by adding /*
, when I am done, remove those two characters.
const walkthroughs = {
a:[
"get hat",
"wear hat",
"x grass",
"smell",
"x box",
"read label",
"open box",
"get crowbar",
"remove hat",
"put it in box",
"close lid",
"crowbar shed",
"east",/*
"get torch",
"out",
"sw",
"turn on torch",
"down",
"turn on light",
/* */
"script on",
]
}
The "script on" after that means that we are automatically recording a transcript afterwards. When you complete a section, you can quickly do SCRIPT WALK to bring up the transcript, paste the new lines into your existing walk-through, and move on to the next bit of the game.
If your walk-thought is a few hundred lines long, it might not be so easy finding the error and parser messages. You can use the HIGHLIGHT command in game after running the walkthrough when in "dev" mode to highlight these messages - a yellow background is added. This only applies to messages already shown; not new messages.
If there is no command line, you can run the command from the developer console; just paste this in:
runCmd('highlight')