Run code upon entering a room? [I6]

Which action should I intercept to run custom code when the player enters a room? The following doesn’t seem to be tripped:

before [; enter: print "we have entered the Grandiossuary"; StartDaemon(Falknir); rfalse;],

Use a daemon instead. The before property will run only on the NEXT turn before anything else happens in the library.

2 Likes

When the player moves between rooms, the before-routine is run for the room that the player leaves, and the after-routine is run for the room that the player enters.

To me, it looks like you could just use after instead of before, and probably catch Go instead of Enter. I believe the Enter action happens when the player enters an object, as in “ENTER CAR”.

3 Likes

Maybe you can try the entry point routine: NewRoom()
DM4:
“Called when the room changes, before any description of it is printed. This happens in the course of any movements or uses of PlayerTo.”

1 Like

how would I safely override NewRoom() so that there is custom handling before the boilerplate handling?

I’m not sure what you mean by ‘next turn’ here; next turn after entering?

NewRoom is an entry point, meaning that it’s defined as an empty function. You can redefine it to do anything you want. You’re not responsible for making anything in particular happen.

1 Like

You have the choice, it all depends on where you want to act: Initial, NewRoom(), description/describe.

Include "parser";
Include "verblib";
Object room1 "In room1"
	with initial "^initial room1",
	! describe "describe room1",
	description "You re in the Room1.",
	n_to room2,
	has light;
Object room2 "In room2"
	with initial "^initial room2",
	describe "describe room2",
	! description "You re in the Room2.",
	s_to room1,
	has light;
[ NewRoom; print "NewRoom() ", (name) location; ]; 
[ Initialise; location = room1; ];
Include "grammar";
Release 1 / Serial number 190723 / Inform v6.34 Library v6.12.3pre

initial room1
NewRoom() In room1
In room1
You re in the Room1.

>n

initial room2
NewRoom() In room2
In room2
describe room2
2 Likes