This module does nothing by itself, but provides an API to handle various types of custom containers.
Requires DataManager!
Has to be require
d 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
cell
cell, 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.location
at 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.
createRecord
containerRefId
refId
of the container spawned incell
containerPacketType
should bespawn
for NPCs and creatures orplace
otherwiseguiseRefId
refId
of the object visually spawned at desired locationguisePacketType
same ascontainerPacketType
collision
whetherguise
should have collision- returns
recordId
, which you can later use to spawn and manipulate containers. Expects any custom records to already exist.
removeRecord
recordId
- removes the record with given
recordId
. Does not remove custom records for givenrefId
s.
getRecordData
recordId
- returns
{ container = { refId, type --packetType }, guise = { refId, type --packetType }, collision }
createContainer
creates acontainer
incell
. Should be used for records with noguise
set.recordId
- returns
instanceId
to be used with other functions later
createContainerAtLocation
same ascreateContainer
, but also spawns theguise
at specificied locationrecordId
cellDescription
location
- returns
instanceId
, same ascreateContainer
removeContainer
removes both theguise
andcontainer
instanceId
getInstanceData
instanceId
- returns
{ recordId, container = { uniqueIndex, cellDescription, --should be the same as `cell` in the config file, unless changed }, guise = { uniqueIndex, cellDescription } }
activateContainer
activatescontainer
from given instance forpid
pid
instanceId
getInventory
returns the inventory ofcontainer
instanceid
setInventory
changes inventory ofcontainer
to giveninventory
instanceId
inventory
addItem
adds the givenitem
(table withrefId
,count
,charge
,enchantmentCharge
andsoul
) to instance's inventoryinstanceId
item
removeExactItem
removes the givenitem
from instance's inventory using inventoryHandler'sremoveExactitem
instanceId
item
removeClosestitem
removes the givenitem
from instance's inventory using inventoryHandler'sremoveClosestitem
instanceId
item
updateinventory
sends necessary packets topid
pid
instanceId
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.