waturi wrote:Suppose I have the same situation except that the pocket watch is now a cigar box with an intricate design. Is there a way I could have the design visible at all times, but only the contents visible when the box is open?
Interesting question, there may be a few ways to go about it but here's what I would do. I am assuming you want the box closed to begin with and containing an item.
1. Make the box a container like you normally would for putting things in.
2. Make that box transparent.
3. Create 2 objects and place them inside the box. 1 will be the design and you can set it's description, name etc. as such. The other will be a compartment for the box which we'll name box_compartment.
4. Make sure both the design and box_compartment are scenery objects and NEITHER of them should be a container.
5. Put the objects you wish the box to contain in the box_container object (even though this object is not actually set as a container).
6. Go to the container tab for the box, and go down to where you can enter scripts for "after opening" and "after closing" the object."
7. Copy these scripts. (You may need to edit the words "box" and "design" in the script so they match up with the actual names of the objects you have already created.)
After Opening:foreach (object, GetDirectChildren(box_compartment)) {
MoveObject (object, box)
}
After Closing:movelist = NewObjectList()
foreach (object, GetDirectChildren(box)) {
list add (movelist, object)
}
list remove (movelist, box_compartment)
list remove (movelist, design)
foreach (object, movelist) {
MoveObject (object, box_compartment)
}
A quick explanation of these steps:
What we're doing is making sure the design is visible at all times by making the box transparent. However, we want the objects inside it to be hidden while the box is closed, so when that is true we're hiding the object inside another object which is not transparent. When the box is opened we want to be able to see and take the objects inside so we need to move them between the box itself (where they can be seen) and the compartment (where they cannot).
The script for on opening is simple enough, we just move everything that's inside the box_compartment to the box. Moving them back is a little more complicated though as we want both the design and the compartment to stay where they are. This is especially important because the box_compartment can't be moved inside itself. To this end we make a list of all the children objects in the box, remove the design and box_compartment from that list, then move the remaining items. The result- the design is still visible after closing it but the objects inside have been hidden away.
If you need any further explanation for any of these steps then let me know. Or if I've missed something obvious (which often happens) I'm sure Sora will be along to correct me shortly