[solved] I7: blocking out exits programmatically(example 38)

I have a question about disabling exits. I want to make it unavailable to get to a certain room at some point in the game. I can do this one exit at a time, but I wanted something more general.

The following code almost works–except MYDIR is identified differently.

[code]“avalanche” by Andrew

room 1 is a room. “Exits in diagonals”

room 2 is northwest of room 1. “This room is a trap”

room 3 is northeast of room 1.

room 4 is southwest of room 1.

room 5 is southeast of room 1.

when play begins:
say “An unfair avalanche strikes!”;
repeat with X running through rooms:
repeat with MYDIR running through directions:
if the room MYDIR from X is room 1:
now nowhere is mapped MYDIR of X; [if I change to southeast it compiles but doesn’t work]

Other things like “now the room MYDIR of X is nowhere” don’t work either.

Any suggestions as to how to keep the code clean and neat and still work this? Thanks!

“change the MYDIR exit of X to nothing” works, I think. Note that this doesn’t change the opposite exit. (See section 3.26 of Writing with Inform.)

Ah-ha…I was looking at section 6.14 of the documentation. I didn’t think to look at the more basic parts.

Also I think I tried “nothing/nowhere is mapped …” … but this makes so much more sense.

Your solution works and is nice and straightforward. I’d tried as many similar phrases as I could, but I guess I missed one. Thanks so much!

Yeah, 6.14 lets you look at the map, but it doesn’t let you change it. I actually found this example by going through the “Maps” section of the Recipe Book – first time I’d ever really used the RB, which I understand can be hard to find things in sometimes, but it was nice that it worked this time.

I was able to at first–and I used it in other parts of the code, so I assumed it worked everywhere.

I’ve never used it, but I like it, since it gives a different way to sort through things than just searching and hoping. It takes some getting used to, though.

At any rate, I really like the “change the X exit to” a lot better. It looks much cleaner and more like real English than what I was trying.

While this example’s probably a one-off coding thing (I agree with the recipe book that we don’t want to do this sort of thing too often,) I got some practice not just relying on the documentation. I’d sort of assumed the documentation was “it” and even ignored the difference between WI and RB in the examples. It was pretty hit and miss. The main frustration I have with all this is that I’ll have 10 questions that should be easily answerable–and 9 are, and the one that isn’t usually could have been easy if only I’d looked at it right.

In a case like this, where you want to disable a bunch of exits at once which all lead to a certain room (or region), it may be more efficient and help prevent bugs to simply use an instead rule.

Instead of going to the inaccessible room when the trap has been sprung, say "You can't go that way."

Wow. You’re right. It’s really nice to have alternate solutions. I’ve learned a lot here.