Thursday, 6 February 2020

Code Reuse

To allow for reuse, the ZILF Game Template should be extended to create a ZILF Game Substrate.

We should start by creating empty copies of the following files.
  • Actions.zil
  • Activities.zil
  • Characters.zil
  • Locations.zil
  • Scenes.zil

Each time the development of a game is finished, the reusable actions and activities should be copied to Actions.zil and Activities.zil in the substrate.

In cases where the actions and activities support an identifiable extension of the ZILF Library, they should be moved into a new file with an appropriate name.

Any library hooks used should be put in a separate file.

The current source code of the ZILF Game Substrate and the ZILF Library Extensions can be downloaded using the links listed on the right.

Monday, 20 January 2020

Cloak of Darkness (concluded)

As promised, I'll now describe how to add score update notification and some necessary control and support. This involves adding actions and activities to the game. For the purpose of this description, actions are made up of verb routines and their associated syntax definitions while activities are made up of support routines. It's helpful to look at the activities first.

The Activities

Score Update Notification

The core functionality works like this.


The score is compared with it's previous value. If there is a difference and the game is not finishing and notification is on, a message is printed to notify the player how many points have been added or subtracted.

Final Score Notification

This is quite straightforward.


A message is printed to notify the player how many points have been scored out of how many available in how many moves. This functionality is wrapped in a replacement for an existing ZILF library routine.

Finishing the Game

This was created as a general mechanism to avoid calling the ZILF library routine JIGS-UP from action routines. This is because doing so means that the final turn never completes, causing the number of turns shown in the final score notification to be one less than the true number.


A finish code, normally zero, is available to be set in action routines. The value one represents winning the game or the standard ending while values of two and above are available to represent various forms of losing the game or alternate endings.

End of Command Activities

Score update notification and finishing the game need to be added to the ZILF library end of turn processing.


After this has been done, score update notification and final score notification work as intended. It only remains to define the control and monitoring actions.

The Actions

Disabling Score Update Notification

The command "NOTIFY OFF" is defined along with it's behaviour.


Enabling Score Update Notification

The command "NOTIFY ON" alias "NOTIFY" is defined along with it's behaviour.


On Demand Score Notification

The command "SCORE" is defined along with it's behaviour.


The complete source code can be downloaded from GitHub.

Wednesday, 15 January 2020

Cloak of Darkness (continued)

Playing this game has three aspects.
  • Exploration,
  • How to Win,
  • How to Lose
 The rules for each of these can be written in ZIL like this ...

The Scenes

Exploring the Opera House

There are only three directions mentioned at the start of the game: north, south and west. The player only finds darkness to the south and is barred from going north by use of an NEXIT.


The only way open for exploration is to the west.

Winning the Game

On going west, the player arrives in the cloakroom. The fact that this is a cloakroom and there is a single hook on one of the walls is meant to suggest that clothing might be left here. If the player asks for the inventory, the following is revealed.

> inventory
You are carrying:
   a velvet cloak (worn)


On examining the cloak, a further clue is revealed.

> examine cloak
A handsome cloak, of velvet trimmed with satin, and slightly spattered with raindrops. Its blackness is so deep that it almost seems to suck light from the room.


This is meant to suggest that the player might be able to go south from the foyer and not find darkness if the cloak is left in the cloakroom. The rules for leaving the cloak in the cloakroom look like this.


The cloak can only be left in the cloakroom and one score point is awarded the first time it is hung on the hook.

Many thanks to Jesse McGrew a.k.a. vaporware for pointing out that the final (ELSE <RFALSE>), which is intended to say "no other verbs are handled by this action routine", is not needed since the COND would cause false to be returned anyway if the ELSE were removed.

After leaving the cloak in the cloakroom and going south from the foyer, a further clue is revealed.

Foyer bar
The bar, much rougher than you'd have guessed after the opulence of the foyer to the north, is completely empty. There seems to be some sort of message scrawled in the sawdust on the floor.


This is meant to suggest that the player should read the message. The rules for reading the message look like this.


A further score point is awarded and the game is won if the number property of the message is less than 2, otherwise the game is lost.

Losing the Game

Points are accumulated towards losing the game by doing anything in the foyer bar while in darkness apart from going north. The rules for awarding these points look like this.


Two losing points are awarded for going in any direction other than north and one losing point is awarded for doing anything else.


Since the original Inform 6 version of this game uses scoring, and score update notification is not yet implemented in the ZILF library, I'll describe how this and other associated features can be added in my next post.

To be continued ...

Monday, 13 January 2020

Cloak of Darkness

This game was originally intended to help new authors of Interactive Fiction decide which authoring system to use. The specification, guidelines and sample implementations can be found here. The ZIL version presented here is a rewrite of the Inform 6 version.

The Locations


This is a very small game which has only three rooms, as presented in the following map. The starting room is outlined in green and the only dark room (the Foyer bar) has a black upper right corner.



The map and its underlying details can be written in ZIL like this.


There are two fixtures in this game: the small brass hook in the Cloakroom and the scrawled message in the Foyer bar. The description of the hook changes depending on whether the cloak (see below) is on it.

The Characters


At the start of the game, the Player Character is wearing a cloak. The game has no other characters.


The Introduction


An introduction is printed at the start of the game.


I'll describe how the game is won, and how this is expressed in ZIL, in my next post.

To be continued ...

Monday, 6 January 2020

ZILF Game Template

For convenience, I recommend starting your ZILF game projects using a template. This is the one I'll be using from now on.


Of course, if your project is not going to be hosted in a Git repository, you can ignore the .gitignore file.