Room's after() called twice

Hi all. I’m relearning Inform 6. Ages ago I wrote a LightToDark routine. It doesn’t make sense to me that Inform doesn’t have one.
Anyway, the manual states that after is called for the room being entered. Running with messages on shows this is not the case. Simple enough, I created a class “Room” with after.
But I noticed it called the after routine twice. Not a huge deal, but why does it do that?

As you type a direction command (e.g. “go north”), the action is set to Go, noun is n_obj, and generic before-routines are run, before the action routine (in this case GoSub) is invoked.

(When I say “generic” before-routines, I mean the library calls react_before for all objects in scope, it calls before for the room and noun, and it calls GamePreRoutine. And analogous for generic after-routines.)

The action routine sends the ##Going fake action to the room you’re about to enter, so the room has a chance to say the player can’t go there. If this before routine returns false, GoSub moves the player to that room. It then sends the fake action ##Going to the after routine of the room you left. If this after routine returns false, it calls the generic after routines with action == ##Go, which will give everything, including the current room, a chance to react.

This is what it looks like if you print the actions sent to the room:


Constant Story "Rule test";
Constant Headline "^A test to see when rules run as you go between rooms.^";

include "parser";
include "verblib";
include "grammar";

Class Room
		print_trace [ prop;
#Ifdef DEBUG;
			print " *** ", (name) self, ".", (string) prop, ": action is ", (DebugAction) action, "^";
		before [; self.print_trace("before"); ],
		after [; self.print_trace("after"); ],
	has light;

Room Room1 "Room 1"
		description "You can see that room 2 lies to the north.",
		n_to Room2;

Room Room2 "Room 2"
		description "You can see that room 1 lies to the south.",
		s_to Room1;

[ Initialise;
 	location = Room1;
#Ifndef DEBUG;
	print "^^You need to compile in DEBUG mode to see what's happening!";
1 Like

Thanks! That clears up a lot. Unfortunately, I just went into work so I can’t try it yet, but I will soon. :+1:
P.S. I should clarify that I’m using the old library because 6.12 hadn’t come out at the time I originally wrote it. (Yes I’m old, and it’s not like riding a bike!)

This may be different in library 6.11

The release notes for 6.12.4 say:

It used to be a bit ambiguous prior to 6.12.x how the “Go” action worked
in a before rule for a room. It is now explicitly set such that the
“Going” action catches the player entering the room and “Go” action
catches the player leaving the room.

6.11 doesn’t have ##Going at all.

This has me confused, since the introducion of ##Going is not mentioned in any of the 6.12.x release notes ( Releases · David Griffith / inform6lib · GitLab ).