Report Rule Not Firing

Hello Everyone!

I haven’t posted here (or really worked on any code or projects) for years, so I’m extremely rusty. I was hoping someone could help me figure out why the Report rule in the following code isn’t being triggered.

The Workspace is a room. 

Spencer is a man in the Workspace. The player is Spencer.
In the Workspace is a woman called Kelsey. 
The zombie is a person in the Workspace.
A ball is in the Workspace.

To adopt is a verb.

Changing perspective to is an action applying to one thing.
Understand "perspective/viewpoint/view/mindset/perspectives/viewpoints/views/mindsets" as "[perspective]".
Understand "change your/my/the/-- [perspective] to/with/-- [something]" as changing perspective.
Understand "adopt the/-- [perspective] of/to/-- [something]" as changing perspective.
Check changing perspective to something which is not a person (this is the block changing perspectives to nonpeople rule):
	say "[We] [see] no reason to assume the perspective of [the noun]." (A) instead.
Check changing perspective to something when the noun is the player (this is the can't change perspective to yourself rule):
	say "[We] [can see] things from [possessive] perspective without changing anything." (A) instead.
Carry out changing perspective to a person (this is the standard carry out changing perspective rule):
	now the player is the noun.
Report changing perspective to something (this is the standard report changing perspective rule):
	say "[We] [adopt] the perspective of [the noun]." (A).

The carry out rule works because the PC does change, but no text from the report rule is printed, as shown in the output:

Workspace
You can see Kelsey, a zombie, and a ball here.

>showme self
yourself - man
location: in the Workspace
singular-named, proper-named; unlit, inedible, portable; male
list grouping key: none
printed name: "Spencer"
printed plural name: "men"
indefinite article: none
description: "As good-looking as ever."
initial appearance: none
carrying capacity: 100

>change view to zombie
>showme self
yourself - person
location: in the Workspace
singular-named, proper-named; unlit, inedible, portable; male
list grouping key: none
printed name: "zombie"
printed plural name: "people"
indefinite article: none
description: none
initial appearance: none
carrying capacity: 100

I’m sure that I’m just overlooking something simple, but I just can’t figure it out. Any help would be appreciated!

Okay, I may have jumped the gun a bit, because I think I’ve gotten it working now. I had to change the report rule to be for any actor and then work around the fact that by that point, [the noun] token is printed as “yourself”.

The Workspace is a room. 

Spencer is a man in the Workspace. The player is Spencer.
In the Workspace is a woman called Kelsey. 
The zombie is a person in the Workspace.
A ball is in the Workspace.

To adopt is a verb.

Changing perspective to is an action applying to one thing.
Understand "perspective/viewpoint/view/mindset/perspectives/viewpoints/views/mindsets" as "[perspective]".
Understand "change your/my/the/-- [perspective] to/with/-- [something]" as changing perspective.
Understand "adopt the/-- [perspective] of/to/-- [something]" as changing perspective.
Check changing perspective to something which is not a person (this is the block changing perspectives to nonpeople rule):
	say "[We] [see] no reason to assume the perspective of [the noun]." (A) instead.
Check changing perspective to something when the noun is the player (this is the can't change perspective to yourself rule):
	say "[We] [can see] things from [possessive] perspective without changing anything." (A) instead.
Carry out changing perspective to a person (this is the standard carry out changing perspective rule):
	let properness be true;
	if the noun is improper-named:
		now properness is false;
	now the player is the noun;
	if properness is false:
		now the player is improper-named.
Report an actor changing perspective to something (this is the standard report changing perspective rule):
	say "[We] [adopt] the perspective of [if the player is improper-named]the [end if][printed name of the noun]." (A);
	now the player is proper-named.

The output for this version is as follows:

Workspace
You can see Kelsey, a zombie, and a ball here.

>change view to zombie
You adopt the perspective of the zombie.

>change view to kelsey
You adopt the perspective of Kelsey.

>change view to ball
You see no reason to assume the perspective of the ball.

If someone could explain exactly what’s happening behind the scenes that requires the Report to be laid out for any actor and/or knows if there is a simpler or more elegant way to handle the bit that reads “[if the player is improper-named]the [end if][printed name of the noun]”, I would still really appreciate the help.

1 Like

I don’t really know what exactly is going on behind the scenes, but changing the player is something of a special case, as it basically means changing the whole perspective mid-action.

See the docs at 8.9. Moving the player :

“A change of player can sometimes cause confusing things to happen, if it takes place as part of a successful action. Suppose there’s an action called “possessing”, which enables the player to possess somebody else’s body; and suppose the player types POSSESS ADELE. The action succeeds, so that the player moves into the mind of Adele. But that means that at the end of the action, the player is no longer the actor - that is, no longer the person who began the action; and consequently, Inform won’t use the report rulebook to say what has just happened. It’s a strange business, moving into another body.”

I think in the given example, I would just move the say statement into the Carry Out rule, even if that’s not generally best practice otherwise.

Carry out changing perspective to a person (this is the standard carry out changing perspective rule):
	say "[We] [adopt] the perspective of [the noun]." (A);
	now the player is the noun.
3 Likes

“Report changing perspective” only covers the player’s action. To handle some other actor’s action, you need to say “Report someone changing perspective” or “Report the actor changing perspective”. (This is mentioned in chapter 12.13.) As StJohn says, this is a weird case because by the time the rules reach the Report stage, the player has changed. So that’s why you need the other form.

You can skip all the properness / improper-named fussing if you save the noun’s name to a variable before switching players:

Switch-name is a text variable.

Carry out changing perspective to a person (this is the standard carry out changing perspective rule):
	now switch-name is the substituted form of "[the noun]";
	now the player is the noun;

Report an actor changing perspective to something (this is the standard report changing perspective rule):
	say "We adopt the perspective of [switch-name].";

Yeah, that’s easiest.

Report and Carry Out are split up to make it easier to apply variable Reports to a single action. But that’s not an issue here. Or if it is, you could just pile up some if statements.

3 Likes

An action is defined by four parameters: actor, action name, noun, and second noun. These are stored as four global variables at the I6 level, with names actor, action, noun and second, respectively.

In addition, at the I6 level, the object identifier for the object that represents the human player’s avatar in the story is stored in a global variable called player.

A rule preamble for an action-based rulebook (such as the Report rulebook, part of the action processing rules) usually includes a description of an action. By convention, omission of any subject in the described action means that the actor is assumed to be the player, and the generated I6 checks whether the actor global has the same value as the player global when deciding whether to apply the rule. Adding a specific actor such as Kelsey changes the check to ensure that the actor variable is set to that specific object’s identifier (and also that that the value of actor and player are different). Adding an actor removes the check of the state of the actor global entirely.

Your carry out rule:

Carry out changing perspective to a person (this is the standard carry out changing perspective rule):
    now the player is the noun.

modifies the value of the player global directly. This occurs in the middle of the action processing rules, prior to the execution of your Report rule. So when the program gets to the check for whether that rule should apply, it evaluates the associated preamble condition, which is

(actor==player) && ((noun ofclass K2_thing))

as meaning to not apply the rule, because the first part is not true at that point. There is a warning about this sort of issue (minus technical details) in the chapter of WWI that StJohnLimbo cites:

A change of player can sometimes cause confusing things to happen, if it takes place as part of a successful action. Suppose there’s an action called “possessing”, which enables the player to possess somebody else’s body; and suppose the player types POSSESS ADELE. The action succeeds, so that the player moves into the mind of Adele. But that means that at the end of the action, the player is no longer the actor - that is, no longer the person who began the action; and consequently, Inform won’t use the report rulebook to say what has just happened. It’s a strange business, moving into another body.

WWI 12.10 Action variables may be relevant if you want a way to make use of zarf’s suggestion but would prefer not to use a global variable for the purpose. And WWI 20.7 Making new text with text substitutions explains what the substituted form of is doing.

4 Likes

Thank you all for the extremely helpful information and example code. I appreciate all the detail, and it’s definitely helped me to understand the way inform handles this better. As for printing the name of the player character in the report rule, I had actually tried to use an action variable and when that didn’t work, a global variable, but I was missing the key phrase the substituted form of to make it work. It’s all functioning properly now, so thanks again!

1 Like