Consolidating actor movement reporting

This is a rather obscure need and ultimately this is just me being fussy, but just in case it’s something that’s already been addressed or there’s an extension out there…

I have multiple NPCs wandering a large house. Sometimes their loops cross and you get multiple reports of their comings and goings, like such:

Michael arrives from the west.
 
Kevin arrives from the northeast.

Susie goes south.

Is there a way to consolidate those messages into one paragraph instead of being broken up into individual line breaks? Combined with other things going on in my rooms, it ends up being an unsightly blast of reports.

Looks like one of the recipe book examples might do you – check out Patient Zero.

3 Likes

Cool, thanks!

Sidebar rant into the ether that has nothing to do with you and your helpful response: whenever I8 comes along I have some suggestions for how the manual could be better.

1 Like

Yeah, agreed – I find the indices and tables of contents aren’t often that helpful. I found that example by googling “Inform 7 ‘arrives from the’”, which I think often works surprisingly well but is probably not the ideal approach.

2 Likes

My mistake is searching the documentation within the application itself.

I’ve been banging my head against trying to strip that recipe book example down to relevant code (there’s just so much of it and it’s very entangled with its game). I don’t know if what I’ve done will even work, but there’s one error remaining that I don’t know what to do with. This line is throwing an error:

make delimiter index of count, continuing;

The error:

You wrote 'make delimiter index of count, continuing'  : but this is a phrase which I don't recognise, possibly because it is one you meant to define but never got round to, or because the wording is wrong (see the Phrasebook section of the Index to check). Alternatively, it may be that the text immediately previous to this was a definition whose ending, normally a full stop, is missing?

I don’t know what that line of code is doing so thereby don’t know where to start troubleshooting it.

Table of Visible Exits
NPC	second	third	heading chosen	total
a person	a person	a person	a direction	a number
with 10 blank rows.

Table of Visible Entrances
NPC	second	third	heading chosen	total
a person	a person	a person	a direction	a number
with 10 blank rows.

To clear (current table - a table name):
	repeat through current table:
		blank out the whole row.

To tidy departures of (current table - a table name):
	let next direction be up;
	repeat through current table:
		if heading chosen entry is next direction:
			let accomplice be NPC entry;
			choose row with heading chosen of next direction in the current table;
			if total entry is 1:
				now second entry is accomplice;
				now total entry is 2;
			if total entry is 2:
				unless the second entry is accomplice:
					now third entry is accomplice;
					now total entry is 3;
			choose row with NPC of accomplice in the current table;
			blank out the whole row;
		otherwise:
			let next direction be heading chosen entry.

The last thing named is a thing that varies. Before printing the name of something (called target) which is not a person: now the last thing named is the target.

Report someone going a direction:
	if the person asked is in the location,
		choose a blank row in the table of visible entrances;
	otherwise choose a blank row in the table of visible exits;
	now NPC entry is the person asked;
	now total entry is 1;
	if the person asked is in the location,
		now heading chosen entry is the opposite of the noun;
	otherwise now heading chosen entry is the noun;
	stop the action.

This is the movement reporting rule:
	sort the Table of Visible Entrances in heading chosen order;
	tidy departures of the table of visible entrances;
	sort the Table of Visible exits in heading chosen order;
	tidy departures of the table of visible exits;
	let total row count be the number of filled rows in the Table of Visible Entrances plus the number of filled rows in the Table of Visible Exits;
	if total row count is 0, rule succeeds;
	generate descriptions from the Table of Visible Entrances;
	generate descriptions from the Table of Visible Exits;
	clear the Table of Visible Entrances; clear the Table of Visible Exits.

To generate descriptions from (current table - a table name):
	let count be the number of filled rows in the current table;
	if count is 0, rule succeeds;
	let index be count;
	repeat through the current table:
		let accomplice be NPC entry;
		if NPC entry is a person, now NPC entry is marked for listing;
		if there is a second entry and second entry is a person, now second entry is marked for listing;
		if there is a third entry and third entry is a person, now third entry is marked for listing;
		let target be the room the heading chosen entry from the location;
		if total entry is 3, say "[The NPC entry], [the second entry], and [the third entry] ";
		if total entry is 2, say "[The NPC entry] and [the second entry] ";
		if total entry is 1:
			if the NPC entry is the last person named, say "[The NPC entry] ";
			otherwise say "[The NPC entry] ";
		if total entry is 1, say "[The NPC entry]s ";
		otherwise say "walk[if total entry is 1]s[end if] ";
		if the NPC entry is in the location:
			if location is indoors and target is indoors, say "over from ";
			if location is outdoors and target is indoors, say "out of ";
			if location is indoors and target is outdoors, say "in from ";
			if location is outdoors and target is outdoors, say "over from ";
		otherwise:
			if location is indoors and target is indoors, say "over to ";
			if location is outdoors and target is indoors, say "into ";
			if location is indoors and target is outdoors, say "out [if a door is visible][the random visible door][end if] to ";
			if location is outdoors and target is outdoors, say "over to ";
		if target is outdoors, say "[the heading chosen entry]";
		otherwise say "[the target]";
		if the total entry is 1 and count is 1 and accomplice carries something, say ", carrying [a list of things carried by the accomplice]";
		decrement index;
		make delimiter index of count, continuing;
		now group size is total entry.

The last person named is a person that varies. Before printing the name of a person (called target): now the last person named is the target. Group size is a number that varies. Group size is 1.

To clear marked people:
	repeat with named party running through people:
		now the named party is not marked for listing.

Would someone be able to lend some advice?

Looks like that’s a phrase that gets defined in the example - I don’t see that in your code pasted above, so I’m guessing you didn’t include that part? It’s right at the end of the very long “recipe.” Hope that helps!

Yeah, deleting that let it compile. But, bleh, this isn’t working. Back to the drawing board.

I think you need to include that phrase, since looks like it’s what closes out the list. Here’s the definition from the example (it’s buried way down at the bottom, after the stuff about describing patients):

To make delimiter (index - a number) of (count - a number), continuing or halting:
    if index is 0:
        if continuing, say ". [run paragraph on]";
        otherwise say ".";
    otherwise if index is 1:
        if count is 2, say " and ";
        otherwise say "[optional comma] and ";
    otherwise:
        say ", ".

To say optional comma:
    if the serial comma option is active:
        say ",".

Does including that (and undeleting the times the phrase is employed) help? If not, what output are you actually seeing?

With or without that chunk of code it’s not printing NPC entrances and exits at all, let alone consolidating them. I think I was being too impatient-- I don’t have doors in my game–so I was simultaneously trying to strip all the door code out too. The example game is so baked into this code that trying remove anything, breaks all of it.

Going to restart by adding back all the code this time, and more-slowly start cutting things out and see what happens.

1 Like

Makes sense – now that I’m looking at your code more closely, I noticed that there’s never a call to follow the movement reporting rule! Looks like you’ll need to add some stuff from the top of Section 1: Errands, since that has an every turn rule that calls the character movement rules, which are defined as a rulebook containing a bunch of stuff including the movement reporting rule (all the stuff about innocent people and mercantile people seems linked to the other parts of the example game so probably can be simplified/discarded, but as you’ve said this is a big example so I definitely don’t have my brain wrapped around it).

3 Likes