[I7] New rule thrice in specific room, only working once

I’m currently coding an easter egg into my game, and I’m debugging at the moment. I’m trying to make xyzzying multiple times only work in Zizzy Room, and when the last time is triggered have the parser say “Nothing happens.” instead of sending the player to Zizzy Room again.

[code]Section - xyzzy

Xyzzying is an action out of world. Understand “xyzzy” as xyzzying.
Zizzy Room is a room.
After entering Zizzy Room for the first time:
say “Read this carefully, Player. This is important. I’ve brought you to my infamous Zizzy room to berate you by way of history lesson. You seem to know nothing about the history of text adventures, so I’ve done my research to properly educate you so that you can make the right choices in the near future.”.

Before xyzzying when the location is not Zizzy Room:
say “‘Zizzy!’, you proclaim, being instantly teleported to:[line break]”;
move the player to Zizzy Room.

When xyzzying for the second time:
now the printed text for Zizzy Room is “Zizzy Room… again”;
say “Really? I thought you learned something from my words, and you decide to throw it all away by not taking my humble advice?”.

When xyzzying for the third time:
now the printed text for Zizzy Room is “Zizzy Room”;
say “Nothing happens.”.

Instead of doing anything other than xyzzying in Zizzy Room:
say “Nothing happens.”.
[/code]

With a kitchen room added to allow testing the exhaustion of the spell outside of the Zizzy room:

Section - xyzzy

Xyzzying is an action applying to nothing. Understand "xyzzy" as xyzzying.

Carry out xyzzying:
	say "'Zizzy!', you proclaim, being instantly teleported to:[line break]";
	move the player to Zizzy Room.

Zizzy Room is a room. The printed name of Zizzy is  "Zizzy Room".  The player is here. 

Kitchen is north of Zizzy Room. "What a lovely kitchen."

After looking in Zizzy Room for the first time:
	say "Read this carefully, Player. This is important. I've brought you to my infamous Zizzy room to berate you by way of history lesson. You seem to know nothing about the history of text adventures, so I've done my research to properly educate you so that you can make the right choices in the near future.".

Instead of xyzzying for the second time:
	now the printed name of Zizzy Room is "Zizzy Room... again";
	say "Really? I thought you learned something from my words, and you decide to throw it all away by not taking my humble advice?";
	move the player to Zizzy.
   
Instead of xyzzying for more than the third time:
	now the printed name of Zizzy Room is "Zizzy Room exhausted... The spell only works in this room now.";
	if the player is not in Zizzy Room: 
		say "Nothing happens.";
   	else:
		continue the action.

Let me know how it works for you.

There are a few problems with your code.

There’s no such thing as a “When xyzzying” rule. The rulebooks attached to actions are Instead, Before, Check, Carry out, After, and Report.
For out-of-world actions, only Check, Carry out, and Report work. So you’ll need to make your xyzzying rules one of these (or else rethink your decision to make it an out-of-world action).

“After entering Zizzy Room for the first time” won’t do anything, because “entering Zizzy Room” doesn’t correspond to any action in Inform. The player is reaching Zizzy Room via the xyzzying action, so you need a “Carry out xyzzying for the first time” rule. (Note—not “After”, since xyzzying is out-of-world.)

“Instead of doing anything other than xyzzying in Zizzy Room” will prevent the player doing anything anywhere, except xyzzying in the Zizzy room. You mean “Instead of doing anything other than xyzzying when the player is in Zizzy Room”. But Instead rules don’t affect xyzzying anyway, so this is the same as “Instead of doing anything in Zizzy Room”.
But note this will prevent the automatic look action that takes place when you move the player to Zizzy Room. So the room name never gets printed. So either except looking from the Instead rule, or else bypass the automatic look, and print the room name yourself.

The Zizzy Room doesn’t have a “printed text”, it has a “printed name”. Also, you’re changing it too late, after it’s been printed; so the new “Zizzy Room… again?” name will never get displayed. You need either to change it at an earlier stage (maybe when the player leaves the room on the previous occasion), or else deal with the change of name a different way, maybe with a text substitution.

Also, shouldn’t there be a way for the player to leave the Zizzy Room? At the moment your Instead rule will prevent that, however it’s supposed to happen.

I’m not sure I’ve understood exactly what you want, but here’s my version.

Section - xyzzy

Xyzzying is an action out of world. Understand "xyzzy" as xyzzying.
Zizzy Room is a room. The printed name of Zizzy Room is "Zizzy Room[if the player is in the Zizzy Room for the second time]... again?[end if]".
Room xyzzyed from is a room that varies.

Check xyzzying in Zizzy Room:
	say "`Zizzy!', you proclaim, and remain exactly where you are." instead.

Check xyzzying when the player has been in the Zizzy room twice:
	say "Nothing happens." instead.

First carry out xyzzying: 
	now room xyzzyed from is the location;
	say "'Zizzy!', you proclaim, being instantly teleported to:[line break]";
	move the player to Zizzy Room, without printing a room description;
	say "[bold type][The location][roman type][line break]".

Carry out xyzzying for the first time:
	say "Read this carefully, Player. This is important. I've brought you to my infamous Zizzy room to berate you by way of history lesson. You seem to know nothing about the history of text adventures, so I've done my research to properly educate you so that you can make the right choices in the near future.".

Carry out xyzzying for the second time:
	now the printed name of Zizzy Room is "Zizzy Room... again";
	say "Really? I thought you learned something from my words, and you decide to throw it all away by not taking my humble advice?"
   
Instead of doing something when the player is in Zizzy Room:
	say "The room seems to fade around you, and you find yourself back in:[line break]";
	move the player to the room xyzzyed from.

How would I set the first paragraph (“Zizzy!’, you proclaim. Nothing happens…[line break][line break]for a few moments, until you are teleported in a cliche cloud of smoke to:[line break]”) to replace ‘Zizzy’ with ‘Plugh’ or ‘Plover’ depending on the command used?

Xyzzy doesn’t take the player to the original room when I use it for the final time, and the “nothing happens” text doesn’t print either.

[code]Office
You scoff at the incessant orders on your screen, quickly becoming bored with your job.

xyzzy
“Zizzy!”, you proclaim. Nothing happens…

for a few moments, until you are teleported in a cliche cloud of smoke to:
Magic Room
Read this carefully, Player. This is important. I’ve brought you to my infamous Magic Room to berate you by way of history lesson. You seem to know nothing about the history of text adventures, so I’ve done my research to properly educate you so that you can make the right choices in the near future.

xyzzy
“Zizzy!”, you proclaim. Nothing happens…

for a few moments, until you are teleported in a cliche cloud of smoke to:
Magic Room… again
Really? I thought you learned something from my narrative spiel, and you decide to throw it all away by not taking my humble advice? What kind of player-character are you?

xyzzy
The room seems to fade around you, and you find yourself back in:
Magic Room… again

xyzzy

Xyzzying is an action out of world. Understand “xyzzy” as xyzzying.
Magic Room is a room.
Room xyzzyed from is a room that varies.
First carry out xyzzying:
now the room xyzzyed from is the location.
Carry out xyzzying for the first time:
say “‘Zizzy!’, you proclaim. Nothing happens…[line break][line break]for a few moments, until you are teleported in a cliche cloud of smoke to:”;
move the player to Magic Room;
say “[bold type][The location][roman type][line break]”;
say “Read this carefully, Player. This is important. I’ve brought you to my infamous Magic Room to berate you by way of history lesson. You seem to know nothing about the history of text adventures, so I’ve done my research to properly educate you so that you can make the right choices in the near future.”.
Carry out xyzzying for the second time:
say “‘Zizzy!’, you proclaim. Nothing happens…[line break][line break]for a few moments, until you are teleported in a cliche cloud of smoke to:”;
now the printed name of Magic Room is “Magic Room… again”;
move the player to Magic Room;
say “[bold type][The location][roman type][line break]”;
say “Really? I thought you learned something from my narrative spiel, and you decide to throw it all away by not taking my humble advice? What kind of player-character are you?”.
Carry out xyzzying for the third time:
say “The room seems to fade around you, and you find yourself back in:”;
move the player to the room xyzzyed from;
say “[bold type][The location][roman type][line break]”.
Check xyzzying when the player has been in the Magic Room twice:
say “Nothing happens.” instead.
[/code]

The “room xyzzyed from” variable is getting set to Magic Room when you xyzzy the second time. To prevent this,

First carry out xyzzying when the location is not the Magic Room: 
	now the room xyzzyed from is the location.

The “if the player has been in the Magic Room twice” condition isn’t doing anything, because the player goes to the Magic Room then stays there (so never goes back a second time). So maybe try something like:

Check xyzzying for more than the third time:
	say "Nothing happens." instead.

(Or maybe “Check xyzzying when the player has been in the Magic Room and the location is not the Magic Room:”)

You don’t want to both print the room name manually and have an auto-look when the player moves, so “move the player to Magic Room, without printing a room description”.

(Sorry, I think I misunderstood what you were trying to do before.)

How would I make it to where the room description for the room xyzzyed from is printed after the bold location line? If I switch the actions, Magic Room is printed instead of Office.

You don’t need to print the name of the return location manually; you could just move the player and let Inform do it’s automatic looking action.

Actually, the way you’ve got it set up now, it would be better to change the name of the Magic Room as needed, and use looking there too. My suggestion to print the room name manually isn’t needed any more. (I’m not sure it was ever a good idea anyway.)

Xyzzying is an action out of world. Understand "xyzzy" as xyzzying.

Magic Room is a room.
Room xyzzyed from is a room that varies.
First carry out xyzzying when the location is not the Magic Room: 
   now the room xyzzyed from is the location.

Carry out xyzzying for the first time:
   say "'Zizzy!', you proclaim. Nothing happens...[line break][line break]for a few moments, until you are teleported in a cliche cloud of smoke to:";
   move the player to Magic Room;
   say "Read this carefully, Player. This is important. I've brought you to my infamous Magic Room to berate you by way of history lesson. You seem to know nothing about the history of text adventures, so I've done my research to properly educate you so that you can make the right choices in the near future.".

Carry out xyzzying for the second time:
   say "'Zizzy!', you proclaim. Nothing happens...[line break][line break]for a few moments, until you are teleported in a cliche cloud of smoke to:";
   now the printed name of Magic Room is "Magic Room... again";
   move the player to Magic Room;
   say "Really? I thought you learned something from my narrative spiel, and you decide to throw it all away by not taking my humble advice? What kind of player-character are you?".

Carry out xyzzying for the third time:
   say "The room seems to fade around you, and you find yourself back in:";
   move the player to the room xyzzyed from;

Check xyzzying for more than the third time:
   say "Nothing happens." instead.

This works better, but the room name was supposed to print because I have a rule set up and it shouldn’t apply here, but I don’t know what I should change in the xyzzy code.

Room headings is a truth state that varies. Room headings is initially true.
The room description heading rule does nothing when room headings is false.
After looking: now room headings is false.
Before going: now room headings is true.

How about adding:

Check xyzzying: now room headings is true.

(By the way, I think all of this would be slightly easier if xyzzying wasn’t out-of-world. If your only reason for making it so is to stop it advancing the turn counter, then “The advance time rule does nothing when xyzzying.” would be an easier way to accomplish that.)

Last thing: How would I change the response for plover or plugh? Carry out xyzzying for the first time: say "'Zizzy!', you proclaim. Nothing happens...[line break][line break]for a few moments, until you are teleported in a cliche cloud of smoke to:"

To say Zizzy:
	let X be word number one in the player's command in lower case;
	if X is:
		-- "xyzzy": say "Zizzy";
		-- "plugh": say "Ploog";
		-- "plover": say "Plover".

Carry out xyzzying for the first time:
	say "'[Zizzy]!', you proclaim. (etc.)

Thank you, it’s perfect!