ThePix / QuestJS

A major re-write of Quest that is written in JavaScript and will run in the browser.
MIT License
66 stars 13 forks source link

How do we suppress "You can see..." when there is nothing in the current room? #3

Closed KVonGit closed 5 years ago

KVonGit commented 5 years ago

Hello, Pix!

How do we stop it from printing "You can see..." and/or "You can go..." when the list count is 0?

ThePix commented 5 years ago

Hiya

The text processor allows you to do that, and there are instructions on its Wiki page (you could already do it for objects, I have updated it so you can do it for exits too). This:

You can use exits and objects to get a list of available exists and a list of objects in the current room. These are useful for the room template. There are also "objectsHere" and "exitsHere" directives that you can wrap the whole thing in so "You can see" only appears if there is actually something here.

const ROOM_TEMPLATE = [
  "%",
  "{exitsHere:You can go {exits}.}",
  "{objectsHere:You can see {objects} here.}",
]