script update
This commit is contained in:
parent
5bf34b8cdb
commit
e85d5bc05d
@ -175,8 +175,14 @@ function cleanUp(_, color)
|
||||
soundCubeApi.playSoundByName("Vacuum")
|
||||
ignoreCustomDataHelper()
|
||||
getTrauma()
|
||||
updateCounters(RESOURCE_GUIDS, 5, "Resources")
|
||||
updateCounters(CLUE_CLICKER_GUIDS, 0, "Clue clickers")
|
||||
|
||||
-- delay to account for potential state change
|
||||
Wait.time(function()
|
||||
updateCounters(RESOURCE_GUIDS, 5, "Resource")
|
||||
updateCounters(CLUE_CLICKER_GUIDS, 0, "Clue clicker")
|
||||
updateCounters(DAMAGE_HORROR_GUIDS, RESET_VALUES, "Damage / Horror")
|
||||
end, 0.2)
|
||||
|
||||
resetSkillTrackers()
|
||||
resetDoomCounter()
|
||||
blessCurseManagerApi.removeAll(color)
|
||||
@ -193,20 +199,16 @@ end
|
||||
-- modular functions, called by other functions
|
||||
---------------------------------------------------------
|
||||
|
||||
function updateCounters(tableOfGUIDs, tableOfNewValues, info)
|
||||
if tonumber(tableOfNewValues) then
|
||||
local value = tableOfNewValues
|
||||
tableOfNewValues = {}
|
||||
for i = 1, #tableOfGUIDs do
|
||||
table.insert(tableOfNewValues, value)
|
||||
end
|
||||
end
|
||||
function updateCounters(tableOfGUIDs, newValues, info)
|
||||
-- instead of a table, this will be used if just a single value is provided
|
||||
local singleValue = tonumber(newValues)
|
||||
|
||||
for i, guid in ipairs(tableOfGUIDs) do
|
||||
local TOKEN = getObjectFromGUID(guid)
|
||||
local newValue = singleValue or newValues[i]
|
||||
|
||||
if TOKEN ~= nil then
|
||||
TOKEN.call("updateVal", tableOfNewValues[i])
|
||||
TOKEN.call("updateVal", newValue)
|
||||
else
|
||||
printToAll(info .. ": No. " .. i .. " could not be found.", "Yellow")
|
||||
end
|
||||
@ -228,10 +230,10 @@ end
|
||||
|
||||
-- reset doom on agenda
|
||||
function resetDoomCounter()
|
||||
local doomcounter = getObjectFromGUID("85c4c6")
|
||||
local doomCounter = getObjectFromGUID("85c4c6")
|
||||
|
||||
if doomcounter ~= nil then
|
||||
doomcounter.call("updateVal")
|
||||
if doomCounter ~= nil then
|
||||
doomCounter.call("updateVal")
|
||||
else
|
||||
printToAll("Doom counter could not be found.", "Yellow")
|
||||
end
|
||||
@ -240,7 +242,9 @@ end
|
||||
-- gets the GUID of a custom data helper (if present) and adds it to the ignore list
|
||||
function ignoreCustomDataHelper()
|
||||
local customDataHelper = playAreaApi.getCustomDataHelper()
|
||||
if customDataHelper then table.insert(IGNORE_GUIDS, customDataHelper.getGUID()) end
|
||||
if customDataHelper then
|
||||
table.insert(IGNORE_GUIDS, customDataHelper.getGUID())
|
||||
end
|
||||
end
|
||||
|
||||
-- read values for trauma from campaign log if enabled
|
||||
@ -271,25 +275,26 @@ end
|
||||
function loadTrauma()
|
||||
-- check if "returnTrauma" function exists to avoid calling nil
|
||||
local trauma = campaignLog.getVar("returnTrauma")
|
||||
|
||||
if trauma ~= nil then
|
||||
printToAll("Trauma values found in campaign log!", "Green")
|
||||
RESET_VALUES = campaignLog.call("returnTrauma")
|
||||
updateCounters(DAMAGE_HORROR_GUIDS, RESET_VALUES, "Damage / Horror")
|
||||
loadingFailedBefore = false
|
||||
loadingFailedBefore = false
|
||||
elseif loadingFailedBefore then
|
||||
printToAll("Trauma values could not be found in campaign log!", "Yellow")
|
||||
printToAll("Default values for health and sanity loaded.", "Yellow")
|
||||
loadingFailedBefore = false
|
||||
loadingFailedBefore = false
|
||||
else
|
||||
-- set campaign log to first state
|
||||
local stateId = campaignLog.getStateId()
|
||||
|
||||
if stateId ~= 1 then
|
||||
campaignLog = campaignLog.setState(1)
|
||||
end
|
||||
loadingFailedBefore = true
|
||||
|
||||
-- small delay to account for potential state change
|
||||
local spawnDelay = 0.1
|
||||
Wait.time(loadTrauma, spawnDelay)
|
||||
Wait.time(loadTrauma, 0.1)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user