Additional Uses for External Containers
As demonstrated in the guide, a really awesome thing you can do with containers is seperate them from the visual 3D object that represents the container.
The video guide demonstrates a couple of uses:
- NPC that has a browsable inventory
- Container that can be scripted to open when certain criteria is met
- Creating a property on the 3D object that can easier reference the linked container it should open
The Project Zip also includes an example that cycles through a series of containers each time the 3D object is opened.
Here are a couple of other things you could do.
ENDER CHESTS
By having multiple 3D objects all linked to the same external container, it would allow for many chests/barrels to share the same contents.
Of course, if these containers are spread across different maps then you would need to have a copy of the container in each map and a syncing process between map loads to ensure what happens in one container is reflected in the other.
[if you would like a more detailed explanation of that process, please let me know]
REMOVING THE 3D OBJECT AFTER USE
If you wish to remove the 3D entity after closing the container, this will currently cause a crash if the container is set directly on the object you wish to remove.
However, if the container is seperate from the 3D Object you wish to remove, then it can be removed effortlessly without any such issues.
To do this,
Query if a container has a specific item
If you want to have a script check if a container holds a certain item, this is the code to do so:
if entity["chest1"] contains "ITEM_0001" then
print("The Apple is in the chest!");
else
print("The chest contains no apples!");
end;
You can also check for a certain amount of an item too, such as this example that checks a container for 50 gold.
if entity["t_chest"] contains[50] "ITEM_0003" then
print("All the Gold is still present!");
else
print("Some gold is missing!!!");
end;