Having groups of responses based on condition

I was wondering if this was possible in Inform …

I am working on a game where you switch points of view throughout. To add to the feel of the story, I would like to switch the default responses depending on whose eyes the player is seeing the world through.

I know I could hard-code each response, like:

The block vaguely going rule response (A) is "[if the player is Sandra]You need to specify a compass direction[otherwise if the player is Emily]This isn't the first time you realize you need direction[otherwise]Pick a direction, any direction[end if]."

But that gets cumbersome.

I’ve thought that a more elegant way would be to put responses in tables, and based on the character the player is controlling, the game would look at a certain table (Table of Sandra Responses, Table of Emily Responses, etc.) for the appropriate response. Not only would that involve fewer if statements (and less typing for me), but I would be able to see all the responses linked to an individual character in a more readable way.

However, I don’t know if this is possible or how I would go about it.

I know Inform 7 moved away from tables for responses (via extensions) years ago, but maybe this is a good use case for it.

Or is there an easier way to do this that I’m missing?

Responses can be redefined at run-time, so one way to handle it is to set up rules or phrases to do that. One simple example:

To update responses based on player:
	if the player is:
			now the block vaguely going response rule (A) is "You need to specify a compass direction.";
			now the block vaguely going response rule (A) is "This isn't the first time you realize you need direction.";
			now the block vaguely going response rule (A) is "Pick a direction, any direction.";

Then wherever in your code you switch the player object, you can just add update responses based on player; immediately after that.

There are lots of ways that you could structure the changeover. That’s just one (untested!) example.


I think that this is a very creative idea! I’m not sure that it’s going to be less work to do it with tables, I’m going to try to do this and post the results here.

1 Like

Thank you! That is a simple way of doing things, and I was overthinking yet again.

I’d be very interested to see your results!