how to make a box can be opened and closed from inside?

I try to make a box a room but it can't close


I would make a second object inside the box, and set it to be scenery, with alias "box", and set open/close on that to open/close the actual box.


I've got a whole bit in my "tutorial game" where you start inside a box and have to open it. I'll attach code here if you think it will be helpful. Pixie's solution will work just fine otherwise.


but because there are two boxes,it ask which one when open/close it,I don't know much about script and just choose make invisiable in the list,then player can't see what is inside when in it...


I'm not sure why you would have two boxes in the same room? One box that you are inside of is a room. When you are outside of the box, you are outside of the "inside the box room" and you have an object box that can be viewed. Whether you are inside the box (room) or outside viewing the box, there is only one box object (which can be opened or closed) and you would not get the 'which box' response.

What am I missing?


When you are outside the box, but the box is open, you can see both boxes.


I thought that being inside the room where the object box is, you would see one box whether it is opened or closed as long as you have a box object and an inside box as a room. Link opening the box to making the 'in' exit visible (or let the enter box command simply move the player to a room called 'inside a box' (or whatever). While in the box, you can have a second box (the one you are in) be examined and set to scenery. Maybe something is lost in translation?! lol

Is that what your original response suggested?


what I want to do is:there is a box in a place,it's a normal container first,but the player can go inside it,so it‘s a container and a room,and the player can hide in it,but in the box room it can’t be closed,I remember it said room can't be closed,if there is a box inside the box room for open/close them both it ask which one,maybe because the box room is also a container?sometimes when there is only the box room it say it can't see that,so I don't understand.....


This is not as straightforward as I first thought. Here is one way to do it.

Create an object, outer_box, in the room, and a second object, inner_object inside the first one. Give them both an alias "box", and suitable descriptions. Set them both to be openable/closeable, and for the script to run on opening paste in this:

inner_box.isopen = true
exit_in.visible = true
outer_box.isopen = true
exit_out.visible = true
msg ("You open the box.")

And for closing:

inner_box.isopen = false
exit_in.visible = false
outer_box.isopen = false
exit_out.visible = false
msg ("You close the box.")

For the outer_box only, on the Setup tab, set it to be a room and an object. Then on the Scripts tab, set the "After entering the room " to:

inner_box.visible = true

and the "Before leaving the room" to:

inner_box.visible = false

For the inner_box only, on the Setup tab, set it to not be visible.

Create exits between the room and the outer_box, name them "exit_in" and "exit_out", and set them both to not be visible.

Here it is in a simple game.

<!--Saved by Quest 5.6.6108.15891-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="box">
    <gameid>51f73e64-5add-4da4-b4cc-0c6321c64ab0</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <object name="outer_box">
      <inherit name="openable" />
      <alias>box</alias>
      <feature_container />
      <look>You look at the outside of the box.</look>
      <openscript type="script">
        inner_box.isopen = true
        exit_in.visible = true
        outer_box.isopen = true
        exit_out.visible = true
        msg ("You open the box.")
      </openscript>
      <closescript type="script">
        inner_box.isopen = false
        exit_in.visible = false
        outer_box.isopen = false
        exit_out.visible = false
        msg ("You close the box.")
      </closescript>
      <enter type="script">
        inner_box.visible = true
      </enter>
      <onexit type="script">
        inner_box.visible = false
      </onexit>
      <object name="inner_box">
        <inherit name="editor_object" />
        <inherit name="openable" />
        <alias>box</alias>
        <feature_container />
        <look>You look at the inside of the box.</look>
        <visible type="boolean">false</visible>
        <openscript type="script">
          inner_box.isopen = true
          exit_in.visible = true
          outer_box.isopen = true
          exit_out.visible = true
          msg ("You open the box.")
        </openscript>
        <closescript type="script">
          inner_box.isopen = false
          exit_in.visible = false
          outer_box.isopen = false
          exit_out.visible = false
          msg ("You close the box.")
        </closescript>
      </object>
      <exit name="exit_out" alias="out" to="room">
        <inherit name="outdirection" />
        <visible type="boolean">false</visible>
      </exit>
    </object>
    <exit name="exit_in" alias="in" to="outer_box">
      <inherit name="indirection" />
      <visible type="boolean">false</visible>
    </exit>
  </object>
</asl>

Thanks,but it should be more difficult,when the box is open player is supposed to see what is inside,I try the simple game but it can't be seen.and when the box is open and player is inside he can see what is inside and outside,when the box is closed player can only see what is inside.


Could you create a new room called box, with exits 'in' and 'out' to the original room with the box in it.
Then create an object 'box' in the room with the box. This object could have a command ( get|climb|go) ( in |into)( the|) (box|) set this to move player to box (room)
The box (room) could have a description like-
first time - script of anything you witness in the box. IE "The guard looks briefly into the room, sees no one and leaves"
Otherwise - "you crouch tensely in the box."
I don't know if that is what you want but it is just a suggestion.


^basically a tweaked version of what I suggested. object box that is a container. room box that is separate but with appropriate descriptions for what can be seen. New Box object can be inside the room box. No conflict. You just have to script for things that can be seen when a flag for open box and closed box is set.


I think it will be too complex without changing the code,maybe it is easier if something can be done before opening/closing


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

Support

Forums