diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..ce3e11f5 --- /dev/null +++ b/.vscode/tasks.json @@ -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 + } + } + ] +} \ No newline at end of file diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 0062dc8d..8f2af116 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -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")