This module does nothing by itself, but provides an API to handle various types of custom containers.
Requires DataManager!
Has to be required before any of the modules that use it.
It is necessary to set allowOnContainerForUnloadedCells = true in scripts/config.lua.
You can find the configuration file in server/data/custom/__config_ContainerFramework.json.
- storage
cellcell, where the actual containers will be placed. Only set this to an unaccessible cell. It will be always kept loaded. If you are using any cell resetting scripts, put this cell to exceptions.locationat which containers will be spawned in thecell.
The following is a list of all functions in this module (and their arguments) you are expected to use in your scripts. If you required it in standard way, they will be accessible from the global ContainerFramework table.
createRecordcontainerRefIdrefIdof the container spawned incellcontainerPacketTypeshould bespawnfor NPCs and creatures orplaceotherwiseguiseRefIdrefIdof the object visually spawned at desired locationguisePacketTypesame ascontainerPacketTypecollisionwhetherguiseshould have collision- returns
recordId, which you can later use to spawn and manipulate containers. Expects any custom records to already exist.
removeRecordrecordId- removes the record with given
recordId. Does not remove custom records for givenrefIds.
getRecordDatarecordId- returns
{ container = { refId, type --packetType }, guise = { refId, type --packetType }, collision }
createContainercreates acontainerincell. Should be used for records with noguiseset.recordId- returns
instanceIdto be used with other functions later
createContainerAtLocationsame ascreateContainer, but also spawns theguiseat specificied locationrecordIdcellDescriptionlocation- returns
instanceId, same ascreateContainer
removeContainerremoves both theguiseandcontainerinstanceId
getInstanceDatainstanceId- returns
{ recordId, container = { uniqueIndex, cellDescription, --should be the same as `cell` in the config file, unless changed }, guise = { uniqueIndex, cellDescription } }
activateContaineractivatescontainerfrom given instance forpidpidinstanceId
getInventoryreturns the inventory ofcontainerinstanceid
setInventorychanges inventory ofcontainerto giveninventoryinstanceIdinventory
addItemadds the givenitem(table withrefId,count,charge,enchantmentChargeandsoul) to instance's inventoryinstanceIditem
removeExactItemremoves the givenitemfrom instance's inventory using inventoryHandler'sremoveExactiteminstanceIditem
removeClosestitemremoves the givenitemfrom instance's inventory using inventoryHandler'sremoveClosestiteminstanceIditem
updateinventorysends necessary packets topidpidinstanceId
setInventory, addItem, removeExactItem and removeClosesItem also have Raw versions (e.g. setInventoryRaw) which do not add or remove custom record links. If you certain you don't need that, use them for better performance.
There is also an event you can catch:
ContainerFramework_OnContainer with arguments {pid, instanceId, index}, where index is the container index you pass to tes3mp.GetContainer... functions.
Has both a Validator and a Handler.