One main issue in dealing with containers is urw treats all contents as fluid, any defining separation of items lost.
Closest I ever got in-game was arrow quivers.
I am inter-oping with C# and memory editing to store the data outside of the game. I'm using some mod files to control the UI and container creation, still pondering what would be required to safely delete a container once I've created it though, maybe require that its emptied first, otherwise item loss can occur. Here is my current progress with the official modding syntax:
[SUBMENU_START:ContainerTest]
.New Container. "Hunting horn" *CARPENTRY* /1/ [EFFORT:1] [PHYS:hands] [noquality]
{Knife} <Small knife> [noquality]
[NAME:(C)Chest]
[WEIGHT:5000]
[TYPE:container]
.New Worn Container. "Hunting horn" *CARPENTRY* /1/ [EFFORT:1] [PHYS:hands] [noquality]
{Knife} <Small knife> [noquality]
[NAME:(W)Pouch]
[WEIGHT:28g]
[TYPE:container]
.Open Container. "Hunting horn" (1) /.1/ [PHYS:hands] [no quality]
{Container} [ground] +'Nearby Containers'
[NAME:Open]
[WEIGHT:0]
.Place Container. "Hunting horn" (1) /.1/ \1h\ [PHYS:hands] [no quality]
{(C)*} (1) +'Container to be placed' [remove]
[NAME:Place]
[WEIGHT:0]
.Wear Container. "Hunting horn" (1) /.1/ [PHYS:hands] [no quality] ///// Not Currently Complete
{(W)*} (1) +'Container to be worn' [remove]
[NAME:Wear]
[WEIGHT:0]
.Takeoff Container. "Hunting horn" (1) /.1/ [PHYS:hands] [no quality] //// Not Currently Complete
{(W)*} (1) +'Container to be worn' [remove]
[NAME:Takeoff]
[WEIGHT:0]
[SUBMENU_END:ContainerTest]
When creating a new container to be used by the engine, the player will use the crafting system to activate when the container created is to be modified and tracked for the engines use... So this would look something like....
Step 1. Craft Container
Step 2. Place/Wear Container using crafting mod
Step 3. C# Mod reads "Place" or "Wear" item created from crafting mod, then modifies this items details to match the designated container. In addition, certain memory that is not used by containers normally will be used to insert an ID that the engine will use to identify that specific container.
Step 4. C# Mod stores the containers real ID and new ID into dictionaries along with information on what item ID's are stored in the container and their quantities. From this, additional properties may be applied in updated versions by taking the ID's and reading the game's item struct for their data, then calculating things such as, how much weight the current container has. This will also be an essential component for interacting w/ and displaying information on the C# UI.
Step 5. C# Mod saves containers data to a readable file, under the current characters file directory. Containers will be saved in a "Containers" folder. The files in the containers folder will relate to each individual container by the unique ID and XY overworld and localworld co-ordinates for location tracking down to the tile. The file name will look like this: "(ID)[x, y|x, y] ItemName.cont". Contained within this file will be data related to the real item ID's for the stored items and their quantities.
Step 6. C# Mod handles loading of containers and condition handling to stop potential bugs from occurring by user error.
Step 7. When "Place" or "Wear" is overwritten in the game's data, and when a new "Place" or "Wear" item is created, it will create a new entry in the players known item struct, allowing new containers to overwrite and repeat.
Step 8. .... many more possible steps I'm missing, but this is the general concept I am shooting for.
This should also allow people to create their own containers that the engine can use, I'm not sure what effects different properties of the crafting system will have. I do know you can insert variables for the crafting system to use via Carb Water Fat and Protein, despite the item not being marked as something that can use these, the data will still be written to where these would be used, and therefor can be used by the engine as user-based input.
Currently, creating your own container looks like this:
.New Container. "Hunting horn" *CARPENTRY* /1/ [EFFORT:1] [PHYS:hands] [noquality]
{Knife} <Small knife> [noquality]
[NAME:(C)Chest]
[WEIGHT:5000]
[TYPE:container]
I'm sure some things could be removed/modified here that aren't needed, but the important thing is the name starts with the engines syntax for identifying containers, (C) represents a container that is placed on the ground, (W) represents a container that can be worn. When the engine identifies a new container has been created via "Place" or "Wear" crafting, it will take the identified container (via looping through the players inventory and detecting which object has decreased in quantity) and copy its data over to the newly created "Place" or "Wear" item, and then mark it for the engine. It will also, remove the (C) or (W) from the containers name, as it is now an active container used by the engine.
I have some additional ideas down the road, but this is as far as I have gotten in concept and code.
If you are interested in the C# source, here is a pastebin link:
https://pastebin.com/gNL03pSiIt will expire in 24 hours, complete source may or may not be released when finished.