Merge pull request #744 from argonui/clean-up-helper

Updated Clean Up Helper
This commit is contained in:
dscarpac 2024-07-04 15:29:37 -05:00 committed by GitHub
commit bd17c40abc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -284,7 +284,6 @@ end
-- maybe ignore cards / decks on the tekelili helper -- maybe ignore cards / decks on the tekelili helper
function maybeIgnoreTekeliliCards() function maybeIgnoreTekeliliCards()
local tekeliliHelper = getTekeliliHelper() local tekeliliHelper = getTekeliliHelper()
if tekeliliHelper then if tekeliliHelper then
removeIgnoreLater = searchLib.onObject(tekeliliHelper, "isCardOrDeck") removeIgnoreLater = searchLib.onObject(tekeliliHelper, "isCardOrDeck")
for _, obj in ipairs(removeIgnoreLater) do for _, obj in ipairs(removeIgnoreLater) do
@ -295,10 +294,7 @@ end
-- clean up for play area -- clean up for play area
function tidyPlayareaCoroutine() function tidyPlayareaCoroutine()
-- small wait to allow other operations to finish coWaitFrames(10)
for k = 1, 10 do
coroutine.yield(0)
end
local trash = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash") local trash = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash")
local playAreaZone = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayAreaZone") local playAreaZone = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayAreaZone")
@ -333,43 +329,46 @@ function tidyPlayerMatCoroutine()
if getOptionValue() then if getOptionValue() then
for _, color in ipairs(COLORS) do for _, color in ipairs(COLORS) do
-- delay for animation purpose
for k = 1, 20 do
coroutine.yield(0)
end
-- get respective trash
local trash = guidReferenceApi.getObjectByOwnerAndType(color, "Trash") local trash = guidReferenceApi.getObjectByOwnerAndType(color, "Trash")
if trash == nil then if trash == nil then
printToAll("Trashcan for " .. color .. " playermat could not be found! Skipping this playermat.", "Yellow") printToAll("Trashcan for " .. color .. " playermat could not be found! Skipping this playermat.", "Yellow")
goto continue else
end coWaitFrames(20)
-- maybe store tekelili cards -- maybe store tekelili cards
if tekeliliHelper then if tekeliliHelper then
tekeliliHelper.call("storeTekelili", color) tekeliliHelper.call("storeTekelili", color)
end end
-- remove objects (with exceptions) -- parse playermat objects
for _, obj in ipairs(playermatApi.searchAroundPlayermat(color)) do for _, obj in ipairs(playermatApi.searchAroundPlayermat(color)) do
maybeTrashObject(obj, trash) -- reset action tokens
end if obj.hasTag("UniversalToken") and obj.is_face_down then
obj.flip()
end
-- reset "activeInvestigatorId" and "...class" -- get rid of temporary tokens
local mat = guidReferenceApi.getObjectByOwnerAndType(color, "Playermat") if obj.hasTag("Temporary") then
mat.setVar("activeInvestigatorId", "00000") trash.putObject(obj)
mat.setVar("activeInvestigatorClass", "Neutral") end
mat.call("updateTexture")
for k = 1, 5 do -- remove objects (with exceptions)
coroutine.yield(0) maybeTrashObject(obj, trash)
end end
-- maybe respawn tekelili cards -- reset "activeInvestigatorId" and "...class"
if tekeliliHelper then local mat = guidReferenceApi.getObjectByOwnerAndType(color, "Playermat")
tekeliliHelper.call("spawnStoredTekelili", color) mat.setVar("activeInvestigatorId", "00000")
mat.setVar("activeInvestigatorClass", "Neutral")
mat.call("updateTexture")
coWaitFrames(5)
-- maybe respawn tekelili cards
if tekeliliHelper then
tekeliliHelper.call("spawnStoredTekelili", color)
end
end end
::continue::
end end
end end
@ -431,3 +430,10 @@ function getOptionValue()
return options["tidyPlayermats"] return options["tidyPlayermats"]
end end
end end
-- pauses the current coroutine for 'frameCount' frames
function coWaitFrames(frameCount)
for k = 1, frameCount do
coroutine.yield(0)
end
end