Re: Quick Inform one-shot messages-- how?


25 Aug 1995 09:18:53 GMT

Fred Sloniker <lazuli@eskimo.com> wrote:
> I'd like to put a mechanism in my evolving game that would allow it to
> make some funny response the first time the player tries something
> pointless, then a duller response on further tries. Is there some
> straightforward way to do this without assigning 14 zillion variables?

Keep an array of the packed addresses of text already seen in the game.
For example:

Constant MAX_MESSAGES 100; ! Number of messages needing storing
Global no_messages = 0; ! Number of messages stored
Array message_text --> MAX_MESSAGES; ! Packed address of messages

[ Message
first ! packed address of message to print first time
other ! packed address to print thereafter
i; ! loop counter
for (i = 0: i < no_messages: i++)
if (message_text-->i == first) {
print (string) other;
return;
}
if (no_messages >= MAX_MESSAGES) "** Out of message space **";
message_text-->no_messages = first;
no_messages ++;
print (string) first;
];

Then the call `Message("~Go away, thou foolish worm!~ bellows the \
Mage.","The Mage ignores your entreaty.");' will do what you want.

If you have thousands of such messages, then it might be worth keeping
the `message_text' array sorted for faster lookup, but for a few hundred
the above inefficient version should run fast enough.

--
Gareth Rees