added a build task and history for last 5 tokens

This commit is contained in:
Chr1Z93 2024-10-26 12:47:35 +02:00
parent fae60c53c5
commit c48271dc39
2 changed files with 52 additions and 0 deletions

24
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,24 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Build with TTS Mod Manager",
"type": "shell",
"command": "go",
"args": [
"run",
"main.go",
"--moddir=C:\\git\\SCED",
"--modfile=${env:USERPROFILE}\\Documents\\My Games\\Tabletop Simulator\\Saves\\composed.json"
],
"options": {
"cwd": "C:\\git\\TTSModManager"
},
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

View File

@ -33,6 +33,7 @@ local chaosTokensLastMatGUID = nil
-- chaos token stat tracking
local tokenDrawingStats = { ["Overall"] = {} }
local lastDrawnTokens = {}
local bagSearchers = {}
local hideTitleSplashWaitFunctionId = nil
@ -594,6 +595,14 @@ function trackChaosToken(tokenName, matGUID, subtract)
tokenName = getReadableTokenName(tokenName)
tokenDrawingStats["Overall"][tokenName] = (tokenDrawingStats["Overall"][tokenName] or 0) + modifier
tokenDrawingStats[matGUID][tokenName] = (tokenDrawingStats[matGUID][tokenName] or 0) + modifier
-- add to list of last drawn tokens (if not subtracting)
if not subtract then
table.insert(lastDrawnTokens, { tokenName = tokenName, matGUID = matGUID })
if #lastDrawnTokens > 5 then
table.remove(lastDrawnTokens, 1)
end
end
end
-- Left-click: print stats, Right-click: reset stats
@ -667,6 +676,25 @@ function handleStatTrackerClick(player, clickType, _)
if clickType == "-3" then return end
printToAll("------------------------------")
-- maybe print history for last 5 token draws
if #lastDrawnTokens > 0 then
local tokenStr = ""
for _, data in ipairs(lastDrawnTokens) do
local mat = getObjectFromGUID(data.matGUID)
if mat ~= nil then
local handColor = mat.getVar("playerColor")
tokenStr = tokenStr .. "[" .. Color.fromString(handColor):toHex() .. "]" .. data.tokenName .. "[-], "
else
tokenStr = tokenStr .. data.tokenName .. " ,"
end
end
-- remove last delimiter
tokenStr = string.sub(tokenStr, 1, -3)
printToAll("Last 5: " .. tokenStr)
end
printToAll(squidKing .. " is an auto-fail magnet.", { 255, 0, 0 })
else
printToAll("No tokens have been drawn yet.", "Yellow")