merge additional player cards
This commit is contained in:
parent
1cbb7e2aa7
commit
2d1de89ab0
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user