Login
Remember
IF Answers
Ask a Question

# How do you create an item which lists all of the things you've examined so far?

0 votes
102 views
asked Oct 17 in Authoring by anonymous

I want to create a memo basically. How would I go about having the memo being updated every-time the player interacts with something? I'd want the player to able to examine the memo at any time, at any place and have a list of things they can check again.

For example, if they checked a table in the game, I'd want the memo to be updated with:

Table
description

- inform7-6l

## 1 Answer

0 votes
answered Oct 19 by Ryan Veeder (290 points)

I can think of a couple ways to pull this off. One is intuitive, but not very efficient. The other is unintuitive but fairly elegant.

    "The Big Memo"

    Warehouse is a room.

    A winch is in warehouse. Description of winch is "A rusty winch. Not worth much."

    A vat is in warehouse. Description of vat is "A large vat, suitable for mixing deadly chemicals."

    A crayon is in warehouse. Description of crayon is "Some kid probably dropped it."

    The player carries a memo.

My first idea was to store the contents of the memo as a text, one that keeps getting more entries added to it:

    Memo entries is text that varies.

    instead of examining the memo:
        if memo entries is "":
            say "The memo is blank.";
        otherwise:
            say "Here's what you've found so far:[paragraph break][memo entries]".

    A thing can be exed.

    After examining something:
        if the noun is not exed:
            now the noun is exed;
            let temp entries be text;
            let temp entries be "[memo entries]";
            now memo entries is "[temp entries][printed name of noun in title case][line break][description of the noun][paragraph break]";
            say "You make a note of it on the memo."

(I always use "exed" to mean "has been examined.")

(This version caused a fatal overflow until I stored the memo entries as "temp entries" before adding to it. I'm not sure where the reference loop was exactly, but this is the safe way to do such things!)

The problem with this is that "memo entries" might need to get really long, and there's a limit to the length of stored text. This solution is memory-intensive! Bad!

Another approach is to rebuild the memo whenever it's examined:

    instead of examining the memo:
        if the number of exed things is 0:
            say "The memo is blank.";
        otherwise:
            say "Here's what you've found so far:[paragraph break]";
            repeat with article running through exed things:
                say "[bold type][printed name of article in title case][roman type][line break][description of article][paragraph break]"

    A thing can be exed.

    After examining something:
        if the noun is not exed:
            now the noun is exed;
            say "You make a note of it on the memo."

I much prefer this version. It's a bit easier to control what kind of line breaks end up where, and it's possible to put parts of the text in bold or italic type (which isn't possible in the previous example, for some reason).

One possible disadvantage is that, unless you include some separate code to reorder the list of exed things, the list in the memo will always display in the built-in order of the items, that is, the order in which they appear in the source text. I think it wouldn't be too difficult to make them display in alphabetical order; I think it would be a bit of an inconvenience to make them display in the order they're examined (which the first method does automatically). Overall, though, I think this generative approach is superior.

## Related questions

- How do I move an item I have more of in the world (since it's a kind of thing)?
- How do I change 'if the player consents'? pre-Inform 6L or post-
- When using hyperlinks, how do you make the command appear appear next to the > instead of on the following line? (Inform 7)
- How to allow an action only if the item is picked up?
- How do you create a multiplayer game?

...