Has the player been to a room? *Solved*


#1

Hello again. I’m guessing this is another bone headedly simple question but… I think my issue is not knowing how to search for certain things… Anyway…
Is there a built in way to tell if a player has been in a specific room? I’d rather not use a bunch of custom variables if there’s a built in method. I’m trying to make the scenery as robust as possible. But it seems awkward to keep describing ‘Franks camp fire off in the distance’ as an unknown flickering light off in the distance. Sooo…
I have tried bits found from several posts but they seem not directly related and have had no real success.
Again Thanks in advance for any clues. Please and thank you actually.
Sincerely,
- Selva


#2

This is tracked by the ‘seen’ property. Even though you can use it directly, it’s more future-proof to use the Actor.hasSeen() method instead, in case you decide to add multiple PCs later on.

if (me.hasSeen(kitchen)) {
    // The PC has seen the kitchen.
}

Note that if the PC has been to the room but it was dark and thus didn’t actually see anything, hasSeen() will still return nil. The seen status is set to true when the Actor performs a lookAroundWithin() in the location and it’s not dark.

This works for all Things, btw, not just rooms. If the object has been described to the Actor in question, hasSeen() will be true for that object:

if (me.hasSeen(blackBox)) {
    // The PC has seen the black box.
}

#3

I didn’t realize rooms even had that property. That works even better than what I was trying. Thank you!!!


#4

That property is in Thing, and since rooms also inherit from Thing, they got that property too.

It might be a good idea looking at the thing.t file. Usually you discover stuff that’s already handled for you but you didn’t know existed.


#5

Ow my head hurts. Thank you for the advice. I fear that the behind the scenes coding might be slightly over my head but I’ll check these first from now on. I’ll try not to be too much of a pest. I appreciate the patience.