I’ve been coding away on my first piece of IF using Inform7 slowly wading through syntax errors etc, but now I am really stuck. I’m trying to implement a detective’s notebook (similar to what is found in Chris Huang’s “An Act of Murder”) that automatically records relevant evidence or clues for the player along with the current time and can be read or consulted later on.
The usage I intended is as follows:
[Items are added to the notebook in the game via code such as:
Note "Matchbook" with "Has Tony's phone number CH 2481.";
The player can use the commands:
> examine notebook
> consult notebook about Matchbook
> read about Matchbook in notebook
> look up Matchbook in notebook
]
I got the basics working with the ability to add items to the notebook during the game and the ability to read the notebook as follows:
Table of Notes
timestamp item detail
a time some text some text
with 50 blank rows
[ Items in the notebook will be stored by unique item and only recorded once.
This makes it easier to have multiple sources giving the same clue.
First time, alert the reader that player he has found a clue. ]
To note (t - some text) with (d - some text):
if the number of blank rows in the Table of Notes is 0:
say ">>Warning: the notebook is now full. (Please file a bug report.)";
rule succeeds;
[ Note: Check to see if the clue is already in the notebook, if so, disregard. ]
if there is an item of t in the Table of Notes:
rule succeeds;
else:
if the number of filled rows in the Table of Notes is 0:
say "You decide to take a note of this in your notebook.";
increase score by 1;
choose a blank row in the Table of Notes;
change timestamp entry to the time of day;
change item entry to t;
change detail entry to d.
[ Examine or Read notebook willl display a list of times, items, but omits detail ]
Instead of examining notebook:
if the number of filled rows in the Table of Notes is 0:
say "Alas your notebook is empty. You still need to find some clues.";
else:
say "The notebook contains [the number of filled rows in the Table of Notes] entries:[line break]";
repeat through the Table of Notes:
say " [timestamp entry] - [detail entry][line break]".
So far this all works fine. But when I try to implement a mechanism for the player to type something like
Consult notebook about matchbook
I tried writing the code below which doesn’t compile because of the use of something in the second and third lines. (It does work properly if I substitute a literal value such as “Matchbook”.
Instead of consulting notebook about something:
if there is a detail corresponding to an item of something in the Table of Notes:
choose row with a item of something in the Table of Notes;
say "[item entry] - [Detail entry][line break]";
else:
[ enable user to look up by time, just in case ]
if there is a timestamp of something in the Table of Notes:
choose row with a timestamp of something in the Table of Notes;
say "[timestamp entry] - [item entry] - [Detail entry][line break]";
else:
[ This never matches! ]
say "There's nothing that matches that item exactly."
I’m really stumped. I have read the built-in docs, the programmer’s guide to Inform7, Jim Aikin’s Guide and Aaron Reed’s book. I have tried half a dozen ways over several hours and I either have compiler errors on the syntax or runtime errors. In Jim Aikin’s book there’s an example of an Encyclopedia that uses Topic as the type in the table. I tried that but then I couldn’t figure out how add new items to the table without getting a runtime error on a statement like:
Note "Matchbook" with "Has Tony's phone number CH 2481.";
If anyone can provide some tips here (or ideally working code!) that is much appreciated.
thanks in advance
–Zack
z-machine-matter.com