How do you empty a container?

I have a few containers in my current game and I’d like to be able to empty a container, rather than getting one object at a time and dropping it. Any ideas how to do this?

After a lot of experimenting and trial and error with some undocumented commands and some help from @adventuron on the syntax, I’ve eventually worked out a way to empty a container. By ‘empty’, I mean dump everything from the container into the room.

I share the code here for anyone else that’s interested. Firstly, define a collection. You have to do this for your containers, anyway. You can re-use the same collection.

collections {
   list_object_buffer : list;
}

Secondly, if your container is openable, define a Boolean variable to indicate its state. Skip this step if it’s not openable.

booleans {
   is_foot_locker_open : boolean "false";
}

Thirdly, do something like this to empty the container (a foot locker, in this case). If the container is not openable, you can skip the test that checks whether it’s not open (!is_foot_locker_open).

   : if (is_present "foot_locker") {
      : match "empty locker" {
         : if (!is_foot_locker_open) {
            : print "You can't empty the foot locker while it's closed.";
            : done;
         }
         : if (child_count "foot_locker" == 0) {
            : print "It's already empty.";
            : done;
         }
         : look_inside extract_the = "id" of = "foot_locker" store_results_in = "list_object_buffer";
         : collection_iterate collection = "list_object_buffer" {
            : create {entity -> (item())}
         }
         : print "You empty the foot locker.";
         : done;
      }
   }
1 Like