Adding Items In Code
A good example of how to add various server constructs in code can be found in worldgen.py. In particular for adding items is the mv3d.server.worldgen.CharacterFactory. Adding a new item is similar to adding anything else to a pool since areas are just pools. At the most basic level, it's this:
charID = yield area.newItem(position, classGen)
area.newItem returns a Deferred that will fire back with the id of the newly created item. In most (but not all!) cases. In this call, position is just a 3d vector to designate the position of the item and classGen is a ClassGenerator instance that should reference the class of the item to be created. The simplest way to supply this is via something like ClassGenerator("mv3d.server.model.physical.PhysicalBox"); however, it can also be specified this way: ClassGenerator().setFrom(PhysicalBox) which requires importing the PhysicalBox class.
Keep in mind that the item may not be created locally. It could be created on any server that is simulating the area. The safest way to get the item after creating it is to use this code:
from mv3d.util.iservice import ISimulationService sim = conductor.getLocalService(ISimulationService) item = yield sim.getItem(charID)
Once you have the item, once again, use it keeping in mind that the local copy you have may not be the authoritative copy.
