[I6]: Doing things the first and subsequent times?

Still very much a newbie, I was wondering if there was a particular solution for a situation one should come across quite often.

For examle, when the player asks the NPC the same question twice, there surely should be a different response to the second question. (“I already told you”, or such.)

I know, this can be realized with flags attached to the situation, raising them etc., but this seems to be a bit cumbersome if it is to be repeated every time, so I wondered if there is a particular mechanism which would help to decide whether any situation is encountered for the first time, or if it’s already “known”, something like –

life[; ask: switch(second){ 'runestone': firsttime("It's an ancient runestone."); "Have you already forgotten?"; }

Or similar.

Is there a mechanism like this in place, or does it have to be reimplemented each time?

Cheers,

syzygy

You could probably do it using the “[stopping]” command inside a text.
See section 5.7 of the documentation, near the bottom.

That’s Inform 7, not Inform 6. Different languages.

You might want to download my EventList extension for I6. (It’s in the if-archive, at http://www.ifarchive.org/indexes/if-archiveXinfocomXcompilersXinform6XlibraryXcontributions.html.) It allows you to create TADS-style event lists of various kinds, including the “stopping” kind. After creating such a list with the replies you want, you can call the list object from your life or orders routine (or from wherever you like).

I use a lot of flags in I6, honestly.

The “general” attribute is great for doing one-shot stuff. Consider this:

Object -> TeflonBlock "teflon block"
  with name "block" "of" "teflon",
  description "It's a block of slippery teflon.",
  before [;
  Take:
    if (self hasnt general) {
      give self general;
      "You try to pick up ", (the) self, " but it slips out of your fingers.";
    }
    print "Carefully, you pick up ", (the) self, " so it doesn't slip.^";
    AttemptToTakeObject(self);
    rtrue;
  ];

Thanks everybody for the replies!

Jim, I’ll check out your library. Sounds promising!

David – So, this is what the “general” attribute is for? Up to now I was a bit stumped as to its purpose…

Cheers,

syzygy

The general attribute is for anything you want to use it for. This is a common case.

The “general” attribute is intended as a catch-all for whatever one-off purpose you can think of. I’ve used it for one-shots, toggling frozen/unfrozen state, and more. For lots more examples of the use of the general attribute, see the source code for my Shadowgate reimplementation.

If you have a lot of oneshot text, you can do something like this:

Constant MAX_ONESHOTS = 100;
Array oneshots --> MAX_ONESHOTS;

[ show_once text i ;
    for (i = 0: i < MAX_ONESHOTS && oneshots-->i != 0 : ++ i) {
        if (oneshots-->i == text)
            return;
    }
    if (i < MAX_ONESHOTS) {
        oneshots-->i = text;
        print (String) text;
    } else {
        print "*** ERROR: Too many oneshots ***^";
    }
];

And make sure that MAX_ONESHOTS is large enough.