How do I get Parchment working?

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!

4 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/

I changed max-width:900px; to max-width:60ch; in the web.css file. It seems to work, but I have a little grey column on the right that is a bit unpleasant.

Thanks for pointing this out, I added it to step 4 now. :+1:

Yes, I didn’t want to complicate things even further. :slight_smile:

Inform 7 looks for Templates in three locations:

  • project-specific templates in <Project Name>.materials\Templates, which if present take priority over
  • user-wide templates in C:\Users\<Username>\Documents\Inform\Templates, which if present take priority over
  • internally supplied templates in <Installation Directory>\Inform7\Internal\Templates.

A potential problem with overwriting the latter location is that (I assume) it will be clobbered when Inform 7 is re-installed.

That’s why I thought it would be best to use the project-specific directory for this one-off case (and that’s also the way it’s described in 25.11):

Inform also supports the use of any other interpreter the author wants to try (including, for instance, later versions of Parchment or Quixe than the built-in ones). If we have access to an exotic Javascript-based interpreter called, let’s say, “Urbzig”, then we can install it by putting it into the “Templates” subfolder of the “.materials” folder for the project, and then ask for it to be used instead of “Parchment” like so:
Release along with the "Urbzig" interpreter.

(which, as seen above, also works with “Release along with the "Parchment" interpreter.”)

If you’re doing it for several projects, it would probably be best to use the middle option and put the template in C:\Users\<Username>\Documents\Inform\Templates.

2 Likes

Thanks again. That’s really good to know. When I was poking around in the Program Files (x86) folders, I also found the templates for the html files. As these are chock full of html validation errors, I can fix them there and keep a backup somewhere for when they get clobbered during an upgrade.

I didn’t realise that any of the Parchment stuff was in the Inform 7 documentation. I guess I should have a browse through it one of these days.