Chaining Several Games Together - ThePix/QuestJS GitHub Wiki

If you are hosting your game on your own web site it would be pretty easy to link a set of games together. To get from one game to another, use a simple HTML link. The built-in link directive in the text processor is probably not ideal, as it opens the new page in its own tab. In fact, it is probably better to do it in code, say when the player uses a certain exit:

window.location.href = "http://example.com/new_url.html"

You can even add some details about the current situation, perhaps setting the player name and the entry point onto the new map. Just add a question mark to the URL, with each name-value pair separated by an ampersand.

window.location.href = "http://example.com/new_url.html?player=Lara&loc=courtyard&score=15"

In the second game, add a bit to settings.setup to process that information. This example just prints the name-value pairs to the console; how you process the data is up to you (I assume if you are contemplating this you have competence at coding!).

settings.setup = function() {
  arrival()
  const data = window.location.href.split('?')[1]
  console.log(data.split('&'))
}

You could link to as many games as you like, and allow the player to jump back and forth through them. They could be written by different authors and even hosted at different locations across the world. It would be possible to have a fully extensible virtual world, with a hub where players start, allowing them to create a character that travels from one world to another, in an ever extending virtual universe.

Notes

This is open to abuse; a cheat could type a fake URL into the address bar of his browser, and give himself a huge score. That will not have any adverse effects on your web site, but it may well allow him to complete your game more easily. If that is a concern, some sort of checking system could be used by adding extra name-value pairs, though no system is going to be completely secure.

There is a limit to the total length of a URL. In MS Internet Explorer and Edge this is 2,083 in the address bar, but I think up to 5000 should be okay way used in manner for IE and 10,000 for Edge. Android is limited to about 8000 in the address bar, but besides that other browsers should be fine.

I cannot see a way this will work for games hosted on Text Adventures because of the way players land on a launch page, at which point the continuity data will be lost.

Worth saying that I have not tried this except to confirm window.location.href works...