merge additional player cards

This commit is contained in:
Chr1Z93 2024-11-12 23:25:51 +01:00
parent 1cbb7e2aa7
commit 2d1de89ab0

View File

@ -111,7 +111,28 @@ function importFromToken()
if objData.Nickname == "Additional Player Cards" then
local additionalIndex = guidReferenceApi.getObjectByOwnerAndType("Mythos", "AdditionalPlayerCardsBag")
if additionalIndex then
objData.GUID = additionalIndex.getGUID()
spawnData.position = additionalIndex.getPosition()
-- merge contained objects
local existingIndexData = additionalIndex.getData()
objData.ContainedObjects = objData.ContainedObjects or {}
-- lookup table by Nickname
local containedObjectLookUp = {}
for _, deepData in ipairs(objData.ContainedObjects) do
if deepData.Nickname ~= "" then
containedObjectLookUp[deepData.Nickname] = true
end
end
-- add existing objects to new box
for _, deepData in ipairs(existingIndexData.ContainedObjects or {}) do
if deepData.Nickname ~= "" and containedObjectLookUp[deepData.Nickname] ~= true then
table.insert(objData.ContainedObjects, deepData)
end
end
additionalIndex.destruct()
end
else