Tdarcos wrote:If placed in the "before" event, this works to show the phrases correctly, but for some reason the door isn't locked.
I think your door actually does get locked in your code from your first post, but you don't know that it's been locked because the before property gets called even
before the library checks to see whether door is locked.
Tdarcos wrote:Now, once the fridge is opened then the 'after' event never gets called at all.
Hmm. Your after event is for DoOpen as well.
I've had a lot of confusion about what is checked for or not checked for in before properties, so this is just a hunch. Roody or someone might be able to give you a definitive answer, but here's my take:
I believe that once the fridge is open, trying to open again will by default fail, meaning that it returns somewhere in the deafault library code. The door can't be opened when it's already opened. Therefore, the action never passes to the "after" layer.
Tdarcos wrote:Apparently I can have a before event, or an after event, but not both.
I'm pretty sure you can have both, but if you want both to be called in the same turn, for the same action, then you have to explicitly return false in the before property in order to pass to after.
Tdarcos wrote:Now, I can create my own attribute separate from visited and it works just fine - in the 'after' event - but I just wonder why I can't use 'visited' and why 'locked' won't stick in 'before'.
Well, 'visited' is used by the Library differently from how you're using it here, in order to keep track of which rooms the player character has been to. The Library assigns lots of attribute aliases, so even though your refrigerator is not a room, it's possible that the Library could be using an alias of 'visited' on it. Whether or not that is the case, it's far safer just to use your own attribute, or else to use the generic attribute 'special' that is specifically for us to use for whatever states we want to keep track of.
Setting 'locked' should be perfectly safe and reasonable, however, since you're not using it in a way that contradicts the Library. After your 'after' event is run and the 'locked' attribute therefore applied, do you get the response for 'before' or 'after' when you try opening the fridge again? I think your problem may be that 'before' doesn't check to see if the door is locked.
Tdarcos wrote:But if I change if self is not beenhere to if self is not visited in the above, then the first time condition is not executed.
I think you're far better off with 'beenhere'.