Print or do something when moving between rooms

Hi! I was trying to print something when I move between rooms, the following code that seemed intuitively to be what I’d want to do doesn’t do that, it has very strange behavior where it prints at the wrong times and too many times. What is the right way to do this?


#you
(current player *)

(intro)
                                        (banner)
                                        (enter #room1)

#room1
(room *)
(singleton *)
(name *)                                Room1
(look *)                                You are in Room1.
(from * go #north to #room2)
                                        You go north to Room2.

#room2
(room *)
(singleton *)
(name *)                                Room2
(look *)                                You are in Room2.
(from * go #south to #room1)
                                        You go south to Room1.
1 Like

You should not write messages into the (from * go …) predicate
instead you should use the following predicate

e.g. Room1

(narrate leaving * #north)
    You make a few steps north and finally find yourself in a second Room!

if you want to print this only when room2 is not visited yet, you might use this instead

(narrate leaving * #north)
    ~(#room2 is visited)
    You make a few steps north and finally find yourself in a second Room!

Hope this helps …
–mikawa

1 Like

That helps, thank you!