What is the Z-code?

Hello everyone :wave:. Before starting, I’d like to say that I’m not an experienced person with Inform 7. What I wanna know is… What is the Z-code? I want to change the background color of my game, but it didn’t work. In this forum, everyone is saying that I must compile the game to z-code, but I don’t know what is that. Can someone please tell me? Thank you.

1 Like

It’s a story file format for the z-machine.

You can change the story file of your game by going to the settings tab and click Z-code version 8.

1 Like

I gave an attempt at coding an example for this. Your mileage may vary :slightly_smiling_face:.

From your post, I think you just want to do some basic screen effects like changing the background color and text color. Before trying to change any colors in the code, you need to swich the format that your game uses when it generates the final story file. Normally in Inform7 the default output format is Glulx and not Z8. So if you just open Inform7 and make a new project, start typing code, and then run your game, commands to change text and background color wont work even if you include Emily Short’s Basic Screen Effects. The “Z-code”, as you referenced it, is an alternative to Glulx and in the case of Inform7 we are talking about Z8. So, how exactly do we change the format of the story output in Inform7? I put a screen shot below of how to do it. You need to click the “Settings” tab and switch to Z8.

Once you have made the correct settings change then you can go ahead and try the following test code. This code will change the background blue and text to white at the begining of the game.

"ChangeColorZ8" by "test"

Include Basic Screen Effects by Emily Short.

Technicolor Place is a room.  The description of Technicolor Place is "This is a test."

When play begins:
	turn the background blue;
	say "[white letters]";
	say "This is the begining of the story.  The blue background and white letters are set when play begins.[line break]". 

Note that switching to Z8 introduces some limitations that Glulx does not have. You might want to read up on the differences before fully commiting to Z8 format in order to enable your text / background color formating requirements. I hope this is helpful and have fun learning Inform7!


With the Gargoyle Glk Extensions, there is now no need to change to Z-Code in order to specific per-character colours. Interpreter support is gradually being added. Right now Gargoyle, Windows Glk, and Spatterlight support the extensions, and soon Parchment and hopefully Lectrote will.

If you don’t need per-character colours, then you can just use Glulx Text Effects to set up colours and other formatting options.


Thank you all for your replies :raised_hands: but there’s another problem…
When I try to change the background color, the letter’s background changes, but not the background itself. Here you have an image for understanding better:

At first, I thought it could be a problem about the preview, but when I release my game, the problem persists. Do anyone know why this happens?

The color change applies only from that point on, so you have to clear the screen after setting the background color to get it apply everywhere. Add clear the screen; after the turn the background blue; line.


Will the user still be able to override the author’s color specifications with the preferences file or dialog box?

Depends on the interpreter.

Nothing changed. Other solution, anyone?

If you haven’t started writing your game yet, you could experiment with Adventuron, a system less powerful than Inform 7, but with powerful inbuilt theming features.

start_at = technicolor_place

locations {
   technicolor_place : location "This is a test" header="TECHNO PLACE";

on_startup {
   : print "This is the beginning of the story.\nThe blue background and white letters are set when play begins.";
   : press_any_key;

themes {
   my_theme : theme {
      theme_settings {
         layout = SB G D X O
      status_bar {
         : header_text;
         : fixed_text "YOUR GAME NAME" ;

      colors {
         paper            = #00f
         pen              = #fff
         status_bar_pen   = #00f
         status_bar_paper = #fff
1 Like