Do something when player is moved to a room

I was trying to move the player to a room, but I want to do something when the player enters it, something like this:

"Test"

Room1 is a room.
Room2 is a room.
Room3 is a room.

Room2 is north of Room1.

After going to Room2:
	say "going to room3";
	now the player is in Room3.
[ Dosen't work ]
After going to Room3:
	say "hi".

https://snippets.borogove.app/inform7/dhmqtk

“Going” is an action in Inform, so when you use code to directly place the player into Room 3 via the “now…” statement, they’re not actually moving via the usual going action. So you could add something like “try going north” (or whatever) if there’s a map connection between room2 and room3. If that’s not possible, you could maybe do an every turn rule that triggers when the player’s in room3? There are a bunch of different possible approaches, though.

(Of course the easiest thing is to just put the “say ‘hi’” right after “now the player is in Room3”, but I assume that’s not actually viable in your real code).

There is no map connection between the current room and the room I want to go to. The room I’m moving the player to is a kind of room with a carry out rule, so I want to do something like carry out going to.

Do you want the text to be printed after the room description? Try this:

The lab is a room.

The garden is north of the lab. "A beautiful garden."

Instead of jumping:
	move the player to the garden;
	say "hi.";

EDIT: oops! I seem to have missed Mike’s reply entirely.

Would something like this work?

After going to room2:
	Now the player is in room3;
	follow the go-to-room3 rule.

After going to room3:
	follow the go-to-room3 rule.

This is the go-to-room3 rule:
	Say "working!"

I need something like this:

Ending is a kind of room.
Understand the printed name property as describing a room.

Carry out going to an ending (called R):
	say "some words [description of R]";
	end the story finally;

Rule for printing the name of an ending (called R):
	say "Ending | [printed name of R]".

So when you go to the ending room, it ends the story.

1 Like

So basically this?

Instead of jumping:
	Move the player to room3;
	Follow the go-to-ending rule.

After going to an ending:
	Follow the go-to-ending rule.

This is the go-to-ending rule:
	say "some words [description of location]";
	end the story finally;
1 Like

Strikes me as a good use of an activity.

lab is room.

To teleport the player to (r - room): carry out the moving the player to activity with r.

moving the player to something is an activity on rooms.

For moving the player to a room (called destination): now the player is in the destination.

after moving the player to the attic: say "my god, how did I get here?"


lab is a room.
parlor is north of lab.
attic is a room.

instead of waiting:
  teleport the player to the attic.

test me with "n / s / z".
3 Likes

Oh, I think I misunderstood. You might be after something more like:

an endgame is a kind of room.
an endgame has a rule called the endgame-rule.

lab is a room.
parlor is an endgame.
The endgame-rule of the parlor is the parlor-endgame rule.
parlor is north of lab.

first after going to an endgame (called resting-place): follow the endgame-rule of the resting-place.

This is the parlor-endgame rule:
  say "oh hai";
  end the story finally.

or if all of the endgame rules are of the form “say something and die”…

an endgame is a kind of room.
an endgame has a text called the eulogy.

lab is a room.
parlor is an endgame.
the eulogy of the parlor is "i can haz ending?".
parlor is north of lab.

first after going to an endgame (called resting-place): 
  say the eulogy of the resting-place;
  end the story finally.

… i.e., what Mike just said. :grinning:

2 Likes

I think this was what I was looking for, so I can do something like end with ending easiest ending.
Like this:

"Test"

[ works ]

lab is room.
Ending is a kind of room.
Easy is an ending.

To end with ending (e - ending):
	carry out the moving the player to activity with e;
	end the story finally.

moving the player to something is an activity on rooms.

For moving the player to a room (called destination): now the player is in the destination.

instead of jumping:
  end with ending easy.
2 Likes