Skip to content

No Command Line

ThePix edited this page Aug 18, 2021 · 20 revisions

A big decision when creating a text adventure is whether the player will type commands into the command bar to interact with the world or will use the list of items and the compass rose in the side panes. It is important because it does not just affect how your game looks but also how you create it.

This page is not in anyway saying whether you should or should not disable text input - it very much depends on you and your game. If you are considering it, here are some things to think about.

Game play considerations

Text Input

Inputting text via the command bar is the traditional input method for interactive fiction. It offers the most flexibility to the player, creating a great sense (or illusion at least) of freedom. At the same time, this puts extra demands on the creator, as she has to anticipate all reasonable commands. If an object is mentioned in a room description, many players will expect to be able to look at it. You will also need to think of all possible synonyms for objects and verbs, because who knows what the player will try?

No Text Input

I am going to assume a game with all interactions going through the side panes; no text input or hyperlinks (if you want hyperlinks, see here).

If you decide to turn off the command bar, you need to address the limitations of the game panes. There are two parts: the compass rose with a built-in set of commands (going in 12 directions plus LOOK, HELP and WAIT); and the inventories.

Commands without items

The simple way to deal with this is to attach the command to an item. The player cannot do SLEEP, instead he will need to find a bed, and select the "Sleep" verb from that.

It is also possible to modify the side panes, say adding your own custom pane, perhaps called location commands. This could be modified each turn to reflect the current situation. SLEEP is only an option if there is a bed at this location. This is a decidedly more complex solution! See here for more on how to do that.

Commands with multiple items

How will you handle commands with two items, such as PUT BALL IN SACK and ATTACK ORC WITH FIREBALL? There are solutions, but you really need to think of them up front, as they may have a big effect of the game. For example, you may decide there will be no containers or surfaces in your game. It is a reasonable approach, but may make other things difficult to implement, such as putting a battery in a torch.

You could try implementing commands where the second item is implicit. Perhaps USE BATTERY to put the battery in the torch, or STOW BALL to put the ball in your pack. The player could EQUIP FIREBALL in one step, then ATTACK ORC in the next turn.

No hidden exits

The compass also gives a quick indication of what exits are available; you cannot have them buried in the room description, and require the player to work out she can go that way.

No hidden objects

Similarly, the inventory lists tell the player exactly what objects are available at any moment. A lot of parser games will have points where the player has to read the room description to realise an object is there; until it is taken it is just scenery. That does not work in games with no text input.

The up side is that you do not have to implement every object mentioned in a room description.

No mystery about what an object can do

The player is restricted to just a handful of possible actions for an object at any moment. On the plus side, this again makes game creation easier, but puzzles can be much easier to solve.

What do I have to do with this cartridge? Well, if I look at the verbs, one is "Put in machine", so I will try that.

On the plus side, this is a solution to the "guess the verb" problem.

Coding issues

Turning off the text input

This is readily done by setting settings.textInput to false. However, there are some debugging commands you might still want to use, so you might actually want to keep the text input during the development. I therefore recommend setting it to be true when "playMode" is "dev" and not otherwise.

settings.textInput = settings.playMode === 'dev'

Displaying verbs

If the player is interacting only through the side panes it is vitally important that every object has the right set of verbs available at the right time. You can do that with the "heldVerbs", "hereVerbs" and wornVerbs" attributes, as described here.

However, for better control, you might want to look at the "verbFunction". This should be a function that takes a list as its only parameter. You can add to this list any extra verbs. The advantage of this technique is that the verbs you add can be determined by the state of the game. It also allows you to remove verbs you do not want.

Let us suppose we have an NPC, and we are tracking his state with the "state" attribute. At some point, the NPC is injured, and his state become 4. Thereafter it makes no sense to offer a TALK TO verb, so if the state is over 3 we remove the last entry in the list, using pop. However, the player may want to try first aid, so instead we add an ASSIST verb.

  verbFunction:function(list) {
    if (this.state > 3) list.pop()
    if (this.state === 4) list.push("Assist")
  },

This does offer some scope to hide what an item can do, if you are building a puzzle. It does also offer scope for getting the player in an impossible situation. If an item is not showing a vital verb, the player will be stuck, so test carefully!

Remember that you may want the verbs to depend on whether the item is held or not.

Parsing verbs

It is likely that the commands Quest needs to understand are going to be a bit different. I mentioned SLEEP before; if we do that with the bed item, then the command the parser will see is SLEEP BED. There are likely to be a lot of odd commands like this that you will need to implement. On the plus side, because you know the player will not be able to try SLEEP LAMP or SLEEP DOG, the implementation is easier than normal. In fact, we can put all the new commands in an arrange, and use the array to create almost the same command for every one.

const newCmds = [
  { name:'Press button' },
  { name:'Assign crew' },
  { name:'Contact planet' },
  { name:'Countersign', scopeHeld:true },
]

for (let el of newCmds) {
  commands.unshift(new Cmd(el.name, {
    regex:new RegExp('^' + el.name.toLowerCase() + ' (.+)$'),
    attName:el.name.toLowerCase().replace(/ /g, ''),
    objects:[
      {scope:el.scopeHeld ? parser.isHeld : parser.isHere},
    ],
    defmsg:"{pv:item:'be:true} not something you can do that with.",
  }))
}

For the item, you just add the relevant attribute. For the strange machine, give it a "pressbutton" attribute (all lowercase, no spaces). For the computer console, "assigncrew" and "contactplanet", and the crew manifest a "countersign" attribute. Note the last one is set up for items the player is holding.

Clearly for your game you will have your own list, but the rest of the code will work fine in any game.

Scenery items

Sometimes items the player can interact with are mentioned in the room description, and it looks clumsy to then list them. With text input this would be a scenery item, and would not appear in the side pane, but if there is no text input that would prevent the player interacting with it. We need to prevent the item appearing in the room description, but still appear in the side pane list.

This can be done with a simple setting:

settings.sceneryInSidePane = true

Conversations

There are various options for handling chatting to NPCs, some work better with no text input than others. You might want to look here and here.

I like to do this for dynamic conversations, as it puts the options by the side pane, where all other interactions are.

settings.funcForDynamicConv = 'showMenuDiag'

Save and Load

How will the user indicate she wishes to save or load the game?

A relatively simple approach is a save button, and then, when the game starts, have it check if there is a saved game, and if there is, ask the user if she wants to load it.

This code will do the loading part.

settings.saveGameName = 'savegame'
settings.setup = function() {
  if (!saveLoad.testExistsGame(settings.saveGameName)) return
  
  showMenuDiag({
    title:'Load saved game?', 
    text:'I cannot help noticing you have a game saved. Would you like to load your saved game, rather than start again?'
  }, ['Yes, load the saved game', 'No, start again'], function(result) {
  log('here')
    if (result === 'Yes, load the saved game') {
      saveLoad.loadGame(settings.saveGameName)
    }
  }, 'alert-dialog');  
}

How you do the save button depends on where you want it, but for a button in the toolbar, it might look like this:

settings.toolbar = {
  content:function() { return 'Hitpoints: ' + game.player.hitpoints },
  roomdisplay: true,
  buttons:[
    { title: "About", icon: "fa-info", cmd: "about" },
    { title: "Dark mode", icon: "fa-moon", cmd: "dark" },
    { title: "Save", icon: "fa-save", cmd: "save " + settings.saveGameName + " ow" },
  ],
}

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