Moving Objects in a Container
GAGE HOLSTON
11 Dec 2017, 23:37There is a section in my game where you use a locker room to change into sweats/towel, depending on what you need to do.
When you put them on, all your inventory is stored inside a locker.
I want to make it so if you leave the locker room, without closing the locker, everything that was still in the locker is stolen.
I know how to move items from your inventory (the whole, ScopeInventory function) but I don't know how to use it when dealing with containers or basically anything besides the inventory.
How do you do this?
-=Darchy=-
11 Dec 2017, 23:57I think (and I apologise if I'm wrong), you could create a room called stolen_clothes then run a script to move all the items from the locker to the stolen_clothes room when they are stolen.
-=Darchy=-
jmnevil54
12 Dec 2017, 00:26You don't have to make it that hard! All you have to do is put code like this after the message that everything was stolen. (Or vice-versa)
(Change the code, of course...)
MoveObject (Giovanni, Item Storage)
*reads rest of comment
Ah, yes.... The locker....
I would say make the default script the code to steal the clothes, and then make the rest of it the code for when the locker is closed!
Something like... (Don't take this literally...)
After leaving the room...
OnExit (this room) {
if (locker = open) {
msg ("Your clothes were stolen!")
MoveObject (Giovanni, Item Storage)
}
else {
msg ("Good thing you closed the locker...")
}
}

K.V.
12 Dec 2017, 01:08Hello.
Here's the important part (put it on the After leaving script for the locker room):
if (locker.isopen) {
foreach (obj, GetDirectChildren(locker)) {
RemoveObject (obj)
}
}
Here's an example game:
<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Locker Antics">
<gameid>879b4245-1ad7-4fbe-92d5-526b79627bd4</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 name="towel">
<inherit name="editor_object" />
<take />
</object>
<object name="phone">
<inherit name="editor_object" />
<take />
</object>
</object>
<exit alias="north" to="locker room">
<inherit name="northdirection" />
</exit>
</object>
<object name="locker room">
<inherit name="editor_room" />
<onexit type="script">
if (locker.isopen) {
foreach (obj, GetDirectChildren(locker)) {
RemoveObject (obj)
}
}
</onexit>
<object name="locker">
<inherit name="editor_object" />
<inherit name="container_open" />
<feature_container />
<isopen type="boolean">false</isopen>
<listchildren />
</object>
<exit alias="south" to="room">
<inherit name="southdirection" />
</exit>
</object>
</asl>
EDITED
Forgot to check if the locker was open. It's fixed now.