ThePix / QuestJS

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

Regions for rooms #63

Closed Kln95130 closed 2 years ago

Kln95130 commented 3 years ago

Here is one last addition that I think the 1.0 could have. It's a much simpler addition than the others, but it has its utility. Sometimes, a dev wants to separate the rooms in different regions, either to help the player locate themself or to introduce game mechanics (for instance, monsters who cannot enter "safe" rooms).

Rooms would have an added property called region: {String}

The name of the current region could be displayed thanks to a text processor:

/**
 * Additional text processor function to print the name of a region
 * @param {*} arr not used
 * @param {*} params not used
 * @returns the current location's region (or a default string)
 */
tp.text_processors.hereRegion = function(arr, params) {
  return (w[game.player.loc].region) ? w[game.player.loc].region: "Unknown region";
};

In the future, this aspect could be further developed. For instance, having events or even a "w" object tied to a specific region instead of the whole world, which would help reduce the scope of what the script needs to process each time it iterates for checks like isAtLoc() or isHeld().

ThePix commented 3 years ago

I vey much agree that regions are useful. The editor already has this built-in, as a way to split up large games when writing them was vital to me. That said, I am not convinced it warrants a text processor directive.

ThePix commented 2 years ago

I have added a help file to support regions; I think that that is enough. It is more important for the editor, and is already in there. I am going to close this. https://github.com/ThePix/QuestJS/wiki/Handling-regions