How can I have a room be connected to another room depending on a variable? Like, from room A “north” would normally lead to room B, but if variable X==1 then “north” would lead to room C.
(And how would I look up a question like this in the documentation? I always find myself completely helpless when opening the TADS 3 Bookshelf. The Inform 7 search window offers at least some help.
Like most things TADS, there are multiple ways to do this. For me, the most appropriate to a lot of my situations is making use of RoomConnector. Here is a lightly-edited sample from my code:
elevatorOnFloor : RoomConnector
room1 = elevator
room2 = elevator.atLobby ? lobby : hallIntersection
canTravelerPass(traveler) { return (doorman.gotPasswd); }
explainTravelBarrier(traveler) {
"The doorman, ever so politely, will not let you pass
without giving your pass phrase. ";
}
/* invoked just PRIOR to the move */
noteTraversal(traveler) {
if (traveler == gPlayerChar)
"The cage door makes a lot of noise as you get
<<gActor.isIn(elevator) ? 'off' : 'on'>> the elevator.";
}
;
In my example, there are only two floors, so the elevator Room contains the property atLobby. You could as easily assign room2 to any property/variable you cared to. If you need a TravelMessage-like reporting, you could use the noteTraversal method as above.
Apologies, @jjmcc , didn’t see that you were typing when I started my reply!
Note, @Grueslayer , that if you want both options to be TravelMessages you might want to do something like this