The other day, I found myself thinking about the old player-in-a-closed-container situation. For my purposes, I was coding a coffin in a room. Once the player is in the coffin and closes it, I wanted only objects within the coffin to be within reach (and seen).
Of course, it doesn't work out of the box, and I went on this epic quest, updating DoOpen, DoClose, FindLight, ObjectIsLight, and FindObject. I was attempting to code an elaborate system that tried to figure out if the player can be seen from the location and act accordingly. Working against me was the fact that FindObject likes to take for granted that the player object can always be seen, no matter what room is being used with it. I tried so hard to tweak it to work for all occasions, but some instance was always breaking.
It's probably for the best that it never worked because who wants to add all of that code, anyway? Eventually, it occurred to me that the easiest thing an author could do was just to set the coffin as the location when it was closed (and the room to the location when it was opened again). Here is some example code:
No comments:
Post a Comment