How do I get Parchment working?

I’ve been stuffing about all day trying to get Parchment working with a z5 file and I’m not even close to getting it working.

I’ve tried the build from Inform 7 technique. No luck. I’ve tried downloading the latest build from GitHub. No luck. I’ve tried setting default_story: 'story.z5' and get a blank page. I’ve created the base64 JavaScript file and tried setting default_story: 'story.z5.js' and get a blank page. I’ve tried setting default_story: [ "interpreter/story.z5", "interpreter/story.z5.js" ] and get a blank page.

I’ve tried the web version. No luck. Using the first two default_story settings above, I get ‘Unknown storyfile format’. Using the third setting, I get ‘InvalidCharacterError: String contains an invalid character’. The developer’s console indicates this is because of ‘Uncaught SyntaxError: illegal character U+0005’ in the z5 story file.

I’ve scoured intfiction.org and the GitHub repository and done a Google search and I can’t find any installation guide or tutorial or instructions anywhere. The only thing I can find is the brief info on options in the wiki and this is far from complete. It doesn’t even give you formats or defaults or what the constraints are.

Of all the various files in GitHub, I can’t work out which JavaScript and css files are required in which circumstances or what they do. The range of Inform 7 and web files are different.

So, what’s the secret to getting this working? Someone must know.

What exactly is not working with the Inform 7 method?

If you’re not building from within Inform 7, then I’d recommend this as the current best option:

And there’s always the option of just uploading the file somewhere and using the instance at iplayif.com.

I followed Zarf’s instructions to create a minimal Inform 7 game (including the release with interpreter thing), then replaced the story files with my files and changed the filenames in play.html. The resultant page just shows the ‘Parchment’ title followed by 'is an interpreter for Interactive Fiction. Find out more., plus the side bar. The play.html page is chock full of html errors and the link is broken. There is no updated version of this file on GitHub.

I’m about to look at those other two links.

If you’re able to upload it then I can take a look. But if you’re not releasing it from within Inform 7 itself, then just use the new ifsitegen.py tool.

The game isn’t finished yet, but will be hosted on itch.io and needs to be self contained.

Flamin’ python script. I’ll have to download, install and learn how to use python and it still uses the Inform 7 files anyway.

Zarf’s script doesn’t help, as it still relies on the Inform 7 files. I’ve just noticed that play.html loads parchment.min.js, but there is no script by that name. Which scripts should it be loading?

More head banging.

I downloaded the latest version of Inform 7. (Mine was apparently out-of-date. I wouldn’t know, as I never use it.) When including the interpreter, it now creates the parchment.min.js file and I’m able to run the game in a browser, but there’s an io exception, specifically ‘Uncaught TypeError: this.io.input is not a function’ in the afore-mentioned file.

So does anyone have a play.html file that actually works with the latest Parchment scripts? There isn’t one on @Dannii’s GitHub repository.

If I set default_story to story.z5.js, I get ‘Unknown storyfile format’.

If I set default_story to story.z5, I was getting ‘InvalidCharacterError: String contains an invalid character’ and ‘Uncaught SyntaxError: illegal character U+0005’, but now I’m getting the same as above.

I should probably mention that I’m using Firefox 88.0 (64-bit) in case that makes a difference.

Hi Garry,

I don’t know if you’ve tried this already, but I got it to work using these steps:

(Sorry if I’m over-explicit in some steps, but I guess this could also benefit others who find this thread later).

  1. Install Inform 7.

  2. Download the zipped “Parchment for I7” from the “ifcomp” branch of the repo: https://github.com/curiousdannii/parchment/raw/ifcomp/dist/inform7/parchment-for-inform7.zip

  3. Make a minimal new I7 project, let’s call it “TestProject”:

Release along with the "Parchment" interpreter.

The Lab is a room.

(But don’t release yet.)

  1. Edited to add: Create a Templates subdirectory in your project’s Materials directory. (thanks to Garry for pointing this out below)
    Unzip parchment-for-inform7.zip into that Templates directory, so that you now have: TestProject.materials\Templates\Parchment

  2. Release the game in Inform 7. A directory called TestProject.materials\Release will be created, which contains index.html and play.html and a subdirectory “interpreter”.

  3. Download zarf’s script from here: quixe/game2js.py at master · erkyrath/quixe · GitHub and save it into the directory where your real game file (let’s say it’s called yourgame.z5) is.

  4. Go to that directory and execute:
    python game2js.py yourgame.z5 > yourgame.z5.js

Important: We don’t use the --giload argument on the command line here, because that’s for a slightly different way of including the game file later, see the comments in the python script. (Depending on what we do later, including the file resulting from --giload would result in the “String contains an invalid character” error that you mention.)

I was initially confused by this as well, due to this post Parchment for Noobs - #4 by zarf
where zarf gives an example with the --giload argument.

  1. Copy yourgame.z5.js into the directory TestProject.materials\Release\interpreter. (And delete the file TestProject.gblorb.js.)

  2. Open play.html in TestProject.materials\Release with a text editor and replace the game’s filename, so the lines:

parchment_options = {
default_story: [ "interpreter/TestProject.gblorb.js" ],
lib_path: 'interpreter/',
};

become:

parchment_options = {
default_story: [ "interpreter/yourgame.z5.js" ],
lib_path: 'interpreter/',
};

And that should be it!

Apologies if you tried this already, but I thought I’d share how I got it to work. (I tried it with devours.z5, a game from the IF archive.)

Hope this helps!

3 Likes

That error is probably caused by requesting input while in the upper window. That functionality is unsupported in the built-in template of Inform 7 6M62 has, but later updates from Github will support it.

You can never be too explicit when it comes to Inform 7.

I don’t have a Templates sub-folder. Am I supposed to create this manually or is there something I should do in Inform 7 to create this automatically?

You’re a bloody champion! Thank you, thank you, thank you. I got it working. I think the key was to:

  1. Include "Parchment" in the first line of the test project so that it knows exactly which interpreter to include. I’ve never seen this mentioned before.
  2. Delete the existing Inform 7\Internal\Templates\Parchment folder and unzip the downloaded parchment-for-inform7.zip file into the Inform 7\Internal\Templates folder. I had seen reference to the Templates folder, but I just thought this was a generic description. I had no idea that it was tucked away in the program folder’s structure.
  3. Delete all the old files from the game.materials\Release folder.
  4. Don’t use @Dannii’s online script (which is what I had used), but use @zarf’s game2js.py python script without the --giload option.
  5. Buy yourself a crystall ball so that you can look into the minds of the Parchment developers. :grinning:

Edited: Changed point 2 after discovering the existence of the Templates folder.

2 Likes

The .z5 file works directly for me, no need to convert it to .js.

However, I don’t know how to target a particular game from a URL:
https://my_website/parchment/?story= …
It doesn’t work.

Does anyone know how to make the with option work to limit the number of characters displayed per line which was in the form <script>parchment_options = {width: 56};</script> which now no longer works?

Right, sorry, I haven’t added support for URL parameters to the Parchment rewrite yet. However you can set the width through editing the CSS.

I can’t get that working with the current Parchment. I have to use the base64 encoded Javascript version.

Are you using an old version? If so, perhaps something is broken in the current version. I just get InvalidCharacterError: String contains an invalid character. The web developer tools indicate that this is due to Uncaught SyntaxError: illegal character U+0005 in the z5 file.

No, the last one. But the old one seems to work well for targeting Zcode.

Thank you. Can I know exactly where and what value to change in the css to be equivalent to the old option?

This error looks like the story file has been inserted directly into some JS code without base 64 encoding. Or the story file was renamed to .js without any processing?

No, @auraes was talking about the raw z5 file, not the base64 encoded one. The options doco indicates that this is possible, but it doesn’t work. The examples given are default_story: 'stories/mygame.z5' or default_story: [ 'stories/mygame.z5', 'stories/mygame.z5.js' ]. Is this right or wrong?

This is how it is structured for me:

my_website/
   parchment/
      index.html
      dist/
         web/
            game_engine_files
      game/
         my_game.z5

In index.html:

    <script>
        parchment_options = {
            default_story: [ "game/my_game.z5" ],
            lib_path: 'dist/web/',
        };
    </script>

Url to play the game:
https://my_website.com/parchment/