Newbie question about containers

I have a container, a medicine cabinet and inside is a bottle of painkillers. I want the painkillers to only be visible when the cabinet is open. I have it set so it makes the painkillers visible when the cabinet is open, and disappears when it's closed.

Problem is when I click to close the medicine cabinet the parser says it's already closed. Huh?

When it is telling me the container is closed when I never closed it?

How do I make this work.

Also, I want to have a limited number of uses for the bottle of painkillers. How might I accomplish this? Thanks in advance for any help.

Make sure you manually add “open object” script. If you use a script of your own you must also add the open script on your own. Same when you close object manually.

the built-in 'helper' Scripts/Functions (such as: 'open', 'close', 'onopen', 'onclose',etc) really confuse things up, at least for myself anyways...

what actually controls ' being open vs being closed' is the built-in 'isopen' Boolean Attribute, an example in/as code scripting:

medicine_cabinet.isopen = true // it's open
medicine_cabinet.isopen = false // it's closed

so, in your 'open' and 'close' Verbs' scripting, you need to add these lines, an example:

<object name="medicine_cabinet">

  <inherit name="container_closed" />

  <attr name="isopen" type="boolean">false</attr>

  <attr name="open" type="script">
    if (this.isopen) {
      msg ( + " is already open, silly")
    } else {
      this.isopen = true
      msg ("You open the " + + " up.")

  <attr name="close" type="script">
    if (this.isopen) {
      this.isopen = false
      msg ("You close the " + + ".")
    } else {
      msg ( + " is already closed, silly")


  <defaultexpression>You can't open that!</defaultexpression>

  <defaultexpression>You can't open that!</defaultexpression>

Non-coder here, so you just hurt my head :)

Thanks for the help guys. I finally figured out what I was doing wrong.

You should not need to do any scripting at all. Just select it as aclosed container, and tick the transparent checkbox.

I found it. Now to figure out a way to have a bottle of painkillers that run out.

This topic is now closed. Topics are closed after 60 days of inactivity.