Saturday, March 23, 2019

Changing the exits in and out of a room.

Changing exits to a room.

I wanted to post this as I found it interesting. I wanted a room that was a secret room that only became available as a room that you after some task was complete. Here's the code I used.

After examining the snack wall for more than the first time :
    if the player does not have the backroom pass:
        say "Yeap, still nothing here that you want.";
    otherwise:
        if The Shop's Backroom is not adjacent to The Magazine Shop:
            say "Yeap, still nothing... Hold the phone!  You notice that the pegboard has moved a bit from the wall.  You reach out to touch the pegboard and notice that it is actually a door!";
            change the north exit of The Magazine Shop to The Shop's Backroom;
            change the south exit of The Shop's Backroom to The Magazine Shop;
            increase the score by 1;
        otherwise:
            say "This is the snack wall, it appears to act as a door to some back room of sorts.  You look over the snacks.  There's still nothing that really stands out as something you would want."

In this we have three possibilities. One where we don't have an item called backroom pass, in this case, pretty much we want to ignore any other possibility. The other two is if you are "finding" the room for the first time or not.

From this I'm sure that you can extract several other possibilities to changing the exits to and from a room. The thing to remember is that doing only one direction makes the new passage one way. So if you want to connect rooms together in the normal two way passage kind of way, then you must connect the rooms with two connections.

No comments:

Post a Comment

Implementing Help in a Story